% Naive search for subsets of a list with a desired sum

subset15(List,Subset) :-
   subset(List,Subset),
   sumlist(Subset,15).

% subset(L1,L2)
%
% Succeeds if L2 is a subset of L1

subset([],[]).
subset([X|Rest],[X|More]) :- subset(Rest,More).
subset([_|Rest],Subset) :- subset(Rest,Subset).

sumlist([],0).
sumlist([X|Rest],N) :- sumlist(Rest,N1), N is N1+X.
