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: Daniele Peri
Subject: Re: Iteratively calling Prolog from C
Date: Thu, 17 Jul 2003 09:38:33 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624

Daniel Dudley wrote:


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

That is exactly the kind of thing, whatever people want to call it, gprolog does not optimize. Perhaps you miss the discussion with Lindsey Spratt. Unfortunately adding choice points as you do just worsen things. Try your factorial_nd with a large N (maybe factorial is not the right test, you may want to turn it into a sum of integers to waste less time) and see gprolog consume all the stack. A solution would be using global variables inside a repeat-fail loop, which is something I do use, especially to read files. Unfortunately this is not exactly the best solution nor it is always feasible.

Bye





reply via email to

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