Ulisses Dias schrieb: > Hi, > > I will explain my doubt using an example. I have the following rule > to split a list. The first splitted list has the size N. > > split(L,0,[],L). > split([X|Xs],N,[X|Ys],Zs) :- N $> 0, N1 $= N - 1, split(Xs,N1,Ys,Zs). > > In Eclipse I can use it: > > ?- split([1, 2, 3, 4], 2, X1, X2). > X1 = [1, 2] > X2 = [3, 4, 5, 6] > Yes (0.00s cpu, solution 1, maybe more) > > That is ok, but when I dont instantiate the size N, the Eclipse answers: > > N = 0 > X1 = [] > X2 = [1, 2, 3, 4, 5, 6] > Yes (0.00s cpu, solution 1, maybe more) > N = 1 > X1 = [1] > X2 = [2, 3, 4, 5, 6] > Yes (0.02s cpu, solution 2, maybe more) > > ... and goes on. > > But I dont want this answer, I want eclipse to create delayed goals > and wait for new constraints. There is something I'm doing wrong? The base clause split(L,0,[],L). will always instantiate the size for you, as you can see when you trace through the program, unless you ensure that the goal gets delayed. If you want to delay the goal until N is bound, use the suspension mechanism. See chapter 17 in the User Manual. There are several alternatives for delaying goals. Cheers, ThorstenReceived on Wed Oct 15 2008 - 07:35:54 CEST
This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET