Re: ASSERT in SWI Prolog



Hi

Mika wrote:

Hello to all,
I must resolve the following problem:
given one list of facts

fact1.
fact2.
fact3.
fact4.
fact5.

I want to replace a fact with a new fact to insert in the same
position of that replacing, as an example if I want to replace fact2
with a new fact fact6, then the DB becomes therefore:

fact1.
fact6.
fact3.
fact4.
fact5.

in order to eliminate a fact from the DB I use ' retract', but as I
make to insert a new fact in one precise position? It can be to
resolved only using ' asserta' and ' assertz'? Thanks.

You cannot have control on the order of facts.
Test this ...

%%%%% START of KB %%%%%%%%%

a.
s.
d.
f.

%%%%% END of KB %%%%%%%%%%

Open this file in SWI interpreter and
?- listing.


Now see the result.

yours
Advait

.



Relevant Pages