user2254798
user2254798

Reputation: 575

Save asserted facts in Prolog

In prolog, if I assert some fact, for example:

assert(boy(john4)).
assert(boy(john3)).
assert(boy(john2)).
assert(boy(john1)).

How can I save this fact in file?

Upvotes: 2

Views: 1751

Answers (1)

Raivo Laanemets
Raivo Laanemets

Reputation: 1159

If you are using SWI-Prolog then one alternative is the persistency.pl library. You need to declare persisted predicates and their argument types. Then you can use assert_mypred and retract_mypred. More info: http://www.swi-prolog.org/pldoc/doc/swi/library/persistency.pl

Upvotes: 1

Related Questions