[Top][All Lists]

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

Re: Storing multiple solutions in a list

From: Vic Bancroft
Subject: Re: Storing multiple solutions in a list
Date: Sat, 05 Aug 2006 03:08:42 -0400
User-agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929)

Kandan Venkataraman wrote:

Assume I have a predicate defined f(X,Y) taking two parameters.

If X is a variable, or a partially instantiated variable (i.e. it is a structure), then assume X can have multiple solutions depending on the value of Y.

How do I store the multiple solutions of X in a list. The problem I am having is that once X is bound to a value, I am
unable to unbind it , to find the next solution to store in the list.

You might consider simply using bagof/3 or setof/3 depending on whether you would mind duplicate solutions. If this is for a class assignment, the classic solution is use recursion as in and a clever one is to use a difference list . . .


"The future is here. It's just not evenly distributed yet."
-- William Gibson, quoted by Whitfield Diffie

reply via email to

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