生成一个3 * 3网格的N * N网格,如下所示 [[x,y,z],[a,b,c],[u,i,o]],其中x,y,z ..等是行,而x,a,u .. 等是列,我们得到了一个相同值的无限循环。
grid_gen(N,M):-
grid_build(N,M1),
grid_add(N,M1),
acceptable_permutation(M1,M). % this works fine.
grid_gen(N,M):-
\+acceptable_permutation(M1,M), %this works fine.
grid_gen(N,M).
grid_add(_,[]).
grid_add(N,[H|T]):-
grid_add(N,T),
generate_list(N,N,H).
grid_add(_,[]).
grid_add(N,[H|T]):-
grid_add(N,T),
generate_list(N,N,H).