Re: trail stack, global stack
- From: Jan Wielemaker <jan@xxxxxxxxxxxx>
- Date: 25 Jun 2005 13:50:03 GMT
On 2005-06-13, Jens Kilian <jjk@xxxxxxx> wrote:
> "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).
The classical trick is:
with_cleanup(G) :-
findall(G, G, List),
member(G, List).
If your G is nicely deterministic this won't help though as garbage
collection will take care of the junk.
To me it sounds the program is non-deterministic (assuming you did not
forget to raise the stack limits). You can use the graphical tracer to
examine the choicepoints after one iteration.
Cheers --- Jan
.
- Follow-Ups:
- Re: trail stack, global stack
- From: blindsearch
- Re: trail stack, global stack
- References:
- trail stack, global stack
- From: blindsearch
- Re: trail stack, global stack
- From: Jens Kilian
- trail stack, global stack
- Prev by Date: Re: swi-prolog + jpl + suse9.3
- Next by Date: Re: Generating Puzzle Solutions
- Previous by thread: Re: trail stack, global stack
- Next by thread: Re: trail stack, global stack
- Index(es):