我在Prolog很新,并在swi-prolog.org上找到了解决数据的例子.但我无法运行它.我抬头看着same_length而且只有same_length/2没有same_length/1.也是all_distinct/2没有all_distinct/0.http://www.swi-prolog.org/pldoc/man?section=clpfd-sudoku
这是我的错误:
ERROR: d:/.../prolog/sudoku.pl:5:10: Syntax error: Operator expected
% d:/.../prolog/sudoku compiled 0.00 sec, 0 clauses
Warning: The predicates below are not defined. If these are defined
Warning: at runtime using assert/1, use :- dynamic Name/Arity.
Warning:
Warning: all_distinct/1, which is referenced by
Warning: d:/.../prolog/sudoku.pl:16:8: 2-nd clause of blocks/3
Run Code Online (Sandbox Code Playgroud)
这是SWI-Prolog示例的代码:
use_module(library(clpfd)).
sudoku(Rows) :-
length(Rows, 9), maplist(same_length(Rows), Rows),
append(Rows, Vs),
Vs in 1..9,
maplist(all_distinct, Rows),
transpose(Rows, Columns),
maplist(all_distinct, Columns),
Rows = [As,Bs,Cs,Ds,Es,Fs,Gs,Hs,Is],
blocks(As, …Run Code Online (Sandbox Code Playgroud)