member(X,[X| _]). member(X,[_ |T]) :- member(X,T). length([], 0). length([A|B],N) :- length(B,M), N is M+1 . smallest([A],A) :- !. smallest([A|B],N) :- smallest(B,N), NY, !. max(_,Y,Y).