Succeeds if the second argument can be unified with a random permutation of the list represented by the first argument.
Examples
?- random_permutation([], X).
X = []
yes
?- random_permutation([a], X).
X = [a]
yes
?- random_permutation([a], [X|_]).
X = a
yes
?- random_permutation([a, b, c], [a, b, c, d]).
no
?- repeat, random_permutation([a, b, c], X), X = [a, b, c], !.
X = [a,b,c]
yes;
no
?- repeat, random_permutation([a, b, c], X), X = [a, c, b], !.
X = [a,c,b]
yes;
no
?- repeat, random_permutation([a, b, c], X), X = [b, a, c], !.
X = [b,a,c]
yes;
no
?- repeat, random_permutation([a, b, c], X), X = [b, c, a], !.
X = [b,c,a]
yes;
no
?- repeat, random_permutation([a, b, c], X), X = [c, a, b], !.
X = [c,a,b]
yes;
no
?- repeat, random_permutation([a, b, c], X), X = [c, b, a], !.
X = [c,b,a]
yes;
no
?- repeat, random_permutation(X, [a, b, c]), X = [b, c, a], !.
X = [b,c,a]
yes;
no
?- repeat, random_permutation([a, b, X],[c, Y, b]), !.
X = c
Y = a
yes;
no
?- random_permutation(X, Y).
Expected at least on argument to be a list but got: X and: Y
?- random_permutation([a|_], [b|_]).
Expected at least on argument to be a list but got: .(a, _) and: .(b, _)