0

このコードがあるとします:

end_sol_cell(Row,9):-
   not(findall(Value,pos_cell(Row,9,Value),[_])).
end_sol_cell(Row,Col):-
   not(findall(Value,pos_cell(Row,Col,Value),[_])),
   New_Col is Col + 1,
   end_sol_cell(Row,New_Col).

w :- end_sol_cell(1,1), end_sol_cell(2,1).

「w」を呼び出すと、無限ループに入ります。どうすればこの問題を解決できますか?

4

1 に答える 1

0

カットでループしないと思います:

end_sol_cell(Row,9):- !, /* <<< here */
   not(findall(Value,pos_cell(Row,9,Value),[_])).
end_sol_cell(Row,Col):-
   not(findall(Value,pos_cell(Row,Col,Value),[_])),
   New_Col is Col + 1,
   end_sol_cell(Row,New_Col).

しかし、それがまさにあなたが望んでいるものかどうかはわかりません。

さよなら

于 2014-06-04T16:01:28.353 に答える