undo, assert, retract 
Author Message
 undo, assert, retract

Hi ...

Wonder if anyone can help.

I'm trying to write a qualitative simulation program in Sicstus prolog.
Part of it involves performing a sort of depth first search. What I'm
trying to do it this:

I won't go into too much detail, but here's an example.

I assert two instances of c(1). Then, I fail the second line so that as
it backtracks it does a retract(c(1)). What I want to happen is for this
to result in retracting *one* instance of c(1). In fact, it retracts
both of them.

  Any ideas??

        Cheers.  Dave.

eg:

| ?- c(1).

no
| ?- assert(c(1)).

yes
| ?- assert(c(1)),undo(retract(c(1))),fail.                  

no
| ?- c(1).

no
| ?-

========= FOR COMPARISON =========

| ?- c(1).

no
| ?- assert(c(1)).

yes
| ?- assert(c(1)),fail.

no
| ?- c(A).

A = 1 ? ;

A = 1 ? ;

no
| ?-



Mon, 12 Jul 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. retract/assert permission error

2. assert en retract

3. assert, retract - simpler method?

4. assert and retract in embedded prolog systems

5. HELP! Need information about implementing assert/retract

6. assert/retract

7. want a bagoff impl. without assert/retracts

8. BibTeX format references to implementing assert and retract

9. implementing assert/retract in the WAM

10. assert, retract + CProlog,BIM, and Quintus

11. Behavior of assert and retract

12. Assert/Retract rules?

 

 
Powered by phpBB® Forum Software