Różnice
Różnice między wybraną wersją a wersją aktualną.
|
|
— |
pl:prolog:pllib:consulting_file [2019/06/27 15:50] (aktualna) |
| ====== Consulting file ====== |
| {{tag>file read/write memory}} |
| ===== Description ===== |
| Consulting a file |
| |
| |
| **Source**: The Art of Prolog |
| ===== Download ===== |
| Program source code: {{consulting_file.pl}} |
| ===== Listing ===== |
| <code prolog> |
| /* |
| |
| consult_(File) :- |
| |
| The clauses of the program in the file File are read and asserted. |
| |
| */ |
| |
| |
| |
| consult_(File) :- open(File,read,DD), consult_loop(DD), close(DD). |
| |
| |
| |
| consult_loop(DD) :- repeat, read(Clause), process(Clause,DD)), !. |
| |
| |
| |
| process(Clause,DD) :- at_end_of_stream(DD). |
| |
| process(Clause,DD) :- assertz(Clause), fail. |
| |
| |
| |
| % Program 12.9: Consulting a |
| file |
| |
| </code> |
| ===== Comments ===== |
| RTERR: /prolog-pllib-consulting_file.pl:6:8: Syntax error: Illegal start of term |