% For Prova 1.6.3 or later.
% Demonstrate the Mandarax style "solve" with controlled enumeration
%    of solutions.
% Note that the name of the performative "enumerate_solutions"
%    in the goal is not important,
%    it only has to match the performative in the reaction rule.

:- enumerate_solutions(ex008(X)).

rcvMsg(XID,Protocol,From,enumerate_solutions,[X|Xs]) :-
	derive([X|Xs]),
	println([X|Xs]," "),
	% When the following condition is verified, the enumeration stops.
	until([X|Xs]),
	!.

until(ex008(X)) :-
	X>1.
	
ex008(X) :-
	member(X,[1,2,3]).

member(X,[X|Xs]).
member(X,[_|Xs]) :-
	member(X,Xs).
