I have a list of lists, and I need to find the longest one of them. If there are more than one with the same length it\'s the same which it returns. Thanks.
% Correct again. longest(LL,LX) :- findmax(Len,(append(_,[L|_],LL),length(L,Len)),MaxLen), append(_,[LX|_],LL), length(LX,MaxLen). findmax(V,P,Max) :- findall(V,P,L), max(L,Max). max([N],N) :- !. max([N|R],Max) :- max(R,Max2), max3(N,Max2,Max). max3(N,Max2,N) :- N > Max2,!. max3(N,Max2,Max2).