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.
To have the length of longest list:
%sample: longest([[2,1,3],[7,5],[1,8,2,3,1],[2,7,1,4]],L,LEN). longest([L], L, _) :- !. longest([H|T], H, _) :- length(H, N), longest(T, X, N), length(X, M), N > M, !. longest([_|T], X, LEN) :- length(X, LEN), longest(T, X, LEN), !.