title: Prolog solve Sudoku
body: <p>I'm rather new at Prolog and found this example on swi-prolog.org to solve a sudoku. But I can't run it. I looked up same_length and there is only <code>same_length/2</code> not <code>same_length/1</code>. Also <code>all_distinct/2</code> and not <code>all_distinct/0</code>. <a href="http://www.swi-prolog.org/pldoc/man?section=clpfd-sudoku" rel="nofollow noreferrer">http://www.swi-prolog.org/pldoc/man?section=clpfd-sudoku</a></p>
  
  <p>Here are my errors: </p>
  
  <pre><code>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
  </code></pre>
  
  <p>And here is the code of SWI-Prolog example:</p>
  
  <pre><code>    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, Bs, Cs),
          blocks(Ds, Es, Fs),
          blocks(Gs, Hs, Is).
  
  blocks([], [], []). 
  blocks([N1,N2,N3|Ns1], [N4,N5,N6|Ns2], [N7,N8,N9|Ns3]) :-
          all_distinct([N1,N2,N3,N4,N5,N6,N7,N8,N9]),
          blocks(Ns1, Ns2, Ns3).
  
  problem(1, [[_,_,_,_,_,_,_,_,_],
              [_,_,_,_,_,3,_,8,5],
              [_,_,1,_,2,_,_,_,_],
              [_,_,_,5,_,7,_,_,_],
              [_,_,4,_,_,_,1,_,_],
              [_,9,_,_,_,_,_,_,_],
              [5,_,_,_,_,_,_,7,3],
              [_,_,2,_,1,_,_,_,_],
              [_,_,_,_,4,_,_,_,9]]).
  </code></pre>
  
  <p>I hope you can help me to find my mistake.</p>