Re: trail stack, global stack



"blindsearch" <dpatte3@xxxxxxxxxxx> writes:
> Is there anyway to clean up the global and trail stacks during execution?

The classical trick, if your program doesn't need to backtrack (i.e., really
leaves no choice points), is the double negation:

foo :-
\+ \+ some_expensive_computation,
foo.

If you need to pass state around, it gets ugly:

foo(State0) :-
\+ \+ ( some_expensive_computation(State0, State1),
assert(saved_state(State1))
),
retract(saved_state(State)),
!,
foo(State).

--
mailto:jjk@xxxxxxx As the air to a bird, or the sea to a fish,
http://www.bawue.de/~jjk/ so is contempt to the contemptible. [Blake]
http://del.icio.us/jjk
.



Relevant Pages

  • Re: trail stack, global stack
    ... >> Is there anyway to clean up the global and trail stacks during execution? ... > The classical trick, if your program doesn't need to backtrack (i.e., really ... > foo:- ...
    (comp.lang.prolog)
  • Re: Irrational numbers questions
    ... negation comes in that the constructivist holds away. ... constructivist a non-nonfoo is not necessarily a foo. ... winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131 ...
    (sci.math)
  • Re: Implementable Set Theory and Consistency of ZFC
    ... ZFC, with the negation of Infinity. ... I don't know what Foo is and I don't know what ~Foo is. ...
    (sci.math)