Hints to understand splendid program to solve Queens
问题 In Art of Prolog of Sterling & Shapiro, exercise Section 14.1 (v): queens(N,Qs) :- length(Qs,N), place_queens(N,Qs,_,_). place_queens(0,_Qs,_Ups,_Downs). place_queens(I,Qs,Ups,[_|Downs]) :- I > 0, I1 is I-1, place_queens(I1,Qs,[_|Ups] ,Downs), place_queen(I,Qs,Ups,Downs). place_queen(Q,[Q|_],[Q|_],[Q|_]). place_queen(Q,[_|Qs],[_|Ups],[_|Downs] ):- place_queen(Q,Qs,Ups,Downs). It is a splendid program, in 11 lines, which quickly solves the problem of positioning queens on a chessboard. It's