Assert and Retract in Shen Prolog


 

 

'assert' and 'retract' were brought into Shen Prolog with version 34. In order to use these features the relevant predicate has to be declared as dynamic. 'asserta' and 'assertz' (see any introduction to Prolog on the use of these predicates) is used to assert clauses.

(0-) (dynamic male)
[male]

(1-) (defprolog male
       john <--;)
(fn male)

(2-) (prolog? (asserta [[male bill] <--;]))
true

(3-) (prolog? (male bill))
true

(4-) (prolog? (retract [[male bill] <--;]))
true

(5-) (prolog? (male bill))
false

Built by Shen Technology (c) Mark Tarver, September 2021