%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % mul(S,X): X is the product of all numbers in the set S % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% :-consult_lib. mul(S,X) :- mul3(S,1,X). mul3({},X,X). mul3(S,X,Y) :- xless(S,A,SS) & Z is X * A & mul3(SS,Z,Y). % Sample goal: % % {log}=> mul({3,2,4},R). % R = 24