2.1.2 Adding rules from the console
Although we strongly advice to put your program in a file, optionally
edit it and use make/0
to reload it (see section
2.1.4), it is possible to manage facts and rules from the terminal.
The most convenient way to add a few clauses is by consulting the pseudo
file
user
. The input is ended using the system end-of-file
character.
?- [user]. |: hello :- format('Hello world~n'). |: ^D true. ?- hello. Hello world true.
The predicates assertz/1 and retract/1 are alternatives to add and remove rules and facts.