Dimitris Bilidas wrote: >... > The problem I have now is how to get the last position of an element > with a specific value from a list with uninstantiated variables. What I want to > do is to get the position of the last 1, from a list of which all elements must > be either 0 or 1. > > ... > getLastOne1(List, Res):- > M#=length(List), > (foreach(E,List), for(I,1,M), foreach(T,Temp) do > T #= I*E), > Res#=max(Temp). This one works perfectly well, as far as I can tell: ?- L = [A, B, C, D, E], L :: 0 .. 1, getLastOne1(L, Pos), D = 1. L = [A{[0, 1]}, B{[0, 1]}, C{[0, 1]}, 1, E{[0, 1]}] A = A{[0, 1]} B = B{[0, 1]} C = C{[0, 1]} D = 1 E = E{[0, 1]} Pos = Pos{[4, 5]} There are 4 delayed goals. Yes (0.00s cpu) -- JoachimReceived on Wed Feb 06 2008 - 00:42:08 CET
This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET