title: clauses for the same predicate should be grouped
body: <p>Here I want to make a prolog implementation that will generate the list of permutations of n,n+1,...2*n-1, having the absolute difference between 2 consecutive values &lt;=2.
  Ex: for <code>n=4</code> the list on which I make the permutations would be <code>[4,5,6,7]</code> , a valid permutation would be <code>[5,4,6,7]</code> and not a valid one would be <code>[7,4,6,5]</code> because <code>7-4 is 3</code> . The problem is that I get the following error <code>clauses for the same predicate should be grouped</code>. I don't understand what I did wrong..Please help me</p>
  
  <pre><code>domains
      el=integer
      list=el*
      lista=list*
  predicates
      perm(list,list)
      permutations(integer,list)
      delete(integer,list,list)
      generate(integer,lista)
      create(integer,list)
      create_list(integer,integer,list)
      permutations_aux(integer,list)
      diff(list,integer).
  clauses
      create(N,L):-
          M = 2*N,
          create_list(N,M,L).
  
      create_list(N,M,[N|R]):-
          N&lt;M,
          N1=N+1,
          create_list(N1,M,R).
  
      create_list(M,M,[]).
  
      perm([],[]).
      perm(Y,[A|X]):-
          delete(A,Y,Y1),
          perm(Y1,X).
  
      delete(A,[A|X],X).
      delete(A,[B|X],[B|Y]):-
          delete(A,X,Y).
  
      permutations(N,X):-
          create(N,X1),
          perm(X1,X).
          diff(X,2).
  
      permutations_aux(N,X):-
          permutations(N,X).
  
      diff([],_).
      diff([_],_).
      diff([X,Y|T],M):-
          abs(Y-X) &lt;=M,!,
          diff([Y|T],M).
  
      generate(N,R):-
          findall(X,permutations_aux(N,X),R).
  
  
  goal
  generate(4,P),
  write(P).
  </code></pre>