users-prolog
[Top][All Lists]
Advanced

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

Re: Iteratively calling Prolog from C


From: Daniel Dudley
Subject: Re: Iteratively calling Prolog from C
Date: Wed, 16 Jul 2003 20:49:44 +0200

Manuel Carro wrote:

>> Well, without knowing exactly what you are trying to
>> accomplish with recursion, may I venture to suggest that
>> you replace the recursive loop with a repeat-fail type loop
>> (using accumulator variables to store results over
>> backtracking)? Here you get garbage collection for free.
>> You'll find a number of examples on my website:

>    Accumulator variables won't help you on backtracking. 
> Maybe you mean dynamic predicates?  Which example were you
> referring to?

Well, I call them "accumulator" variables, although there
may be a better way to describe them. Factorial_nd is the
simplest example, I believe. Notice how the last
two variables in factorial_nd/5 are used to store values
over backtracking. Otherwise, the same principle is used in
fib_qmat_nd.pl, fib_range_nd.pl, and magic_sq.pl.

Hope this helps.

Daniel




reply via email to

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