~~~
/*
an addition to the puzzle script
that provides opportunity to make
a list of solution
*/
/*
<script type="text/prolog/query">
?-
puzzle(list,7,_solutionz_)
.
_solutionz_ = [{X:0.25981192897362965, Y:0.019894355932532033, Z:0.5982874610961902, T:12.596623556756295}, {X:0.8863074696576477, Y:0.01295705176770758, Z:0.38922835820640816, T:12.595523730001984}, {X:0.7461932764795882, Y:0.12364955304422516, Z:0.5021429194544775, T:12.595967492020305}, {X:0.8382378829859348, Y:0.3389868983865552, Z:0.0985224994664047, T:12.59578911149325}, {X:0.7826710673417634, Y:0.2835821621281403, ... : ..., ... : ...}, {X:0.6176058483799298, ... : ..., ..., ...}, {... : ..., ..., ...}] ;
false.
?-
</script type="text/prolog/query">
*/
puzzle(list,_count_,_solutionz_)
% produce a list of solutions to the puzzle .
% _count_ is any number .
% _solutionz_ is a list of solution with length is _count_ .
:- true
, [] = _solutionz_0_
, _solutionz_ = _solutionz_9_
, puzzle(each,_count_,_solutionz_0_,_solutionz_9_)
.
puzzle(each,_count_,_solutionz_0_,_solutionz_9_)
:- true
% only consider this alternative if there IS NOT SOME _count_ remaining .
% when this happens a new solution IS NOT appended to the incoming list .
% instead the outgoing list "_solutionz_9_"
% is the same as the incoming list "_solutionz_0_" .
, \+ _count_ > 0
, _solutionz_0_ = _solutionz_9_
, true
.
puzzle(each,_count_,_solutionz_0_,_solutionz_9_)
:- true
% only consider this alternative if there IS SOME _count_ remaining .
% when this happens a new solution IS appended to the incoming list .
, _count_ > 0
% the incoming list , with the new solution appended , is the outgoing list
, append(_solutionz_0_,[_solution_],_solutionz_1_)
% solve the puzzle once .
, puzzle(once,_solution_)
% recursively invoke this predicate to get another solution .
, _count_ - 1 #= _count_1_
, puzzle(each,_count_1_,_solutionz_1_,_solutionz_9_)
.
~~~
kintalken
~~~