Maxima Function
random_permutation (a)
Returns a random permutation of the set or list a, as constructed by the Knuth shuffle algorithm.
The return value is a new list, which is distinct from the argument even if all elements happen to be the same. However, the elements of the argument are not copied.
Examples:
(%i1) random_permutation ([a, b, c, 1, 2, 3]); (%o1) [c, 1, 2, 3, a, b] (%i2) random_permutation ([a, b, c, 1, 2, 3]); (%o2) [b, 3, 1, c, a, 2] (%i3) random_permutation ({x + 1, y + 2, z + 3}); (%o3) [y + 2, z + 3, x + 1] (%i4) random_permutation ({x + 1, y + 2, z + 3}); (%o4) [x + 1, y + 2, z + 3]