% smallest(L,X) - X is the smallest value in L.

smallest([X],X).
smallest([H|T],X) :- smallest(T,Y), min(H,Y,X).

% min(V1,V2,M) :- M is the smaller of V1 and V2.

min(V1,V2,V1) :- V2 >= V1.
min(V1,V2,V2) :- V2 < V1.
