We start with an empty database and the following commands are given
assert(q(a,b)),assertz(q(1,2)),asserta(q(foo,blug)).
What does now the database contain?
What happens after the following commands?
retract(q(1,2)),assertz((p(X):-h(X))).
Finally, what happens after the following command?
retract(q(_,_)),fail.
MyAttempt
I introduced the following commands in Prolog
assert(q(a,b)).
assertz(q(1,2)).
asserta(q(foo,blug)).
but it marked an error saying that q should be of 1 parameter and not 2.
Could someone please help me? How can I fix this? Any kind of help would be greatly appreciated
Thank you in advance.
swipl, it works. - Willem Van Onsemswipl. But in a file it makes no sense to doasserta's, etc. as "naked expressions". Sinceasserta(exp)is equal toexpin the head of the file. You can only do these in the body of predicates. - Willem Van Onsem