users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question on assert and retract


From: Vic Bancroft
Subject: Re: question on assert and retract
Date: Mon, 26 Aug 2002 21:49:32 -0400 (EDT)

On Mon, 26 Aug 2002, bruno patin wrote:

> is it normal that two identic call to assertz will have a positive 
> answer ? for example :
> 
> assertz(toto(2)).
> assertz(toto(2)).

Yes, assertz does not check for duplicates.  An interesting way to check the
prolog database is,

  | ?- listing.

  toto(2).
  toto(2).

  yes

This is why you have two bindings for X in 

> toto(X).
> X=2
> yes
> X=2
> no

The 1.2.12 version I have here reports this a bit differently, e.g.,

  | ?- toto(X).

  X = 2 ? ;

  X = 2

  yes

> retract(toto(2)).
> 
> toto(X).
> no

It removes all the clauses that would unify with 2.  The 1.2.12 version gives,

  | ?- retract(toto(2)).

  true ? ;

  yes

Why does your version report "no" ?

more,
l8r,

------------------------------------------------------------------- 
Victor Bancroft, Principal Engineer, Zvolve Systems [v]770.551.4505 
1050 Crown Pointe Pkwy, Suite 300, Atlanta GA 30338 [f]770.551.4509 
Fellow, Artificial Intelligence Center              [v]706.542-0358 
Athens, Georgia  30602, U.S.A           http://ai.uga.edu/~bancroft 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]