. permutation . , , . permutation, :
?- permutation ([a,b,c,r P). = [,,];
[,,]; [,,];
permutation , .
1. , .
2. , [X | L] , . 3.5, L, L1, X L1.
L
L1 |
^ |
L1 - L
X, [ X | L ]
. 3.5. [ | L]
Prolog, .
I. Prolog
permutation ([], [ j). permutation ([X | Lj, P):-
permutation , 11),
insert! X, LI, P).
(X) , , X . :
permutation2 [],[]) permutations (L, [X j P]):-
del{ X, 1, LI),
permutation2{ Ll, p),
. :?- permutation! [ red, blue, green], P).
:
? = I red, blue, green];
= [ red, green, " blue];
p = [ blue, red, green];
p = [ blue, green, red;;
p = [ green, red, blue);
p= I green, blue, red];
no
permutation :?- permutation{ L, [a,b,c]).
, permutation, L . , "", , , . , permutation2, () , . .