[eclipse-clp-users] "twice" similar to "once"

From: Edgaonkar, Shrirang <Shrirang.Edgaonkar_at_...390...>
Date: Tue, 22 Mar 2016 03:18:35 +0000
Dear Clp users,



  Similar to "once / 1" I would like to write "twice / 1" goal so that the first solution backtracks and finds the second solution. I wish to get both the solutions.



I have tried the following:-

I can run Code1 followed by Code2 to get both the solutions.



Code1:

:-lib(ic).
top([A,B]):-
 A :: -100..100,
 B :: -100..100,
 A #> B,
 A #\= -98,
 search([A,B],0,input_order,indomain,complete,[backtrack(0)]).

--------------------------------------------------------------------------------------

Code2:

:-lib(ic).
top([A,B]):-
 A :: -100..100,
 B :: -100..100,
 A #> B,
 A #\= -98,
 search([A,B],0,input_order,indomain,complete,[backtrack(1)]).



But I wish to do something like this.



findall(X,(twice top([A,B])),List) so that List contains both the solutions. I wish to know how does once / 1 is able to fail the goal after first run. Similarly I can make it fail after backtracking one more time. Hope I have written it in detail.



Kindly guide me on how to do this.



Thanks and Regards,

Shrirang Edgaonkar



______________________________________________________________________
Disclaimer: This email and any attachments are sent in strictest confidence
for the sole use of the addressee and may contain legally privileged,
confidential, and proprietary data. If you are not the intended recipient,
please advise the sender by replying promptly to this email and then delete
and destroy this email and any attachments without any further use, copying
or forwarding.
Received on Tue Mar 22 2016 - 03:18:51 CET

This archive was generated by hypermail 2.3.0 : Tue Apr 16 2024 - 09:13:20 CEST