RosettaCodeData/Task/Permutations/Picat/permutations-1.picat

13 lines
278 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
permutation_rec1([X|Y],Z) :-
permutation_rec1(Y,W),
select(X,Z,W).
permutation_rec1([],[]).
permutation_rec2([], []).
permutation_rec2([X], [X]) :-!.
permutation_rec2([T|H], X) :-
permutation_rec2(H, H1),
append(L1, L2, H1),
append(L1, [T], X1),
append(X1, L2, X).