From: Robert D. <rob...@us...> - 2007-04-18 16:26:38
|
Update of /cvsroot/maxima/maxima/doc/info In directory sc8-pr-cvs16:/tmp/cvs-serv1385/doc/info Modified Files: nset.texi Log Message: Description of function random_permutation. Index: nset.texi =================================================================== RCS file: /cvsroot/maxima/maxima/doc/info/nset.texi,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- nset.texi 22 Mar 2007 14:29:18 -0000 1.18 +++ nset.texi 18 Apr 2007 16:26:34 -0000 1.19 @@ -1633,6 +1633,8 @@ @code{permutations} complains if @var{a} is not a literal list or set. +See also @code{random_permutation}. + Examples: @c ===beg=== @@ -1690,6 +1692,36 @@ @end deffn +@deffn {Function} random_permutation (@var{a}) + +Returns a random permutation of the set or list @var{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: + +@c ===beg=== +@c random_permutation ([a, b, c, 1, 2, 3]); +@c random_permutation ([a, b, c, 1, 2, 3]); +@c random_permutation ({x + 1, y + 2, z + 3}); +@c random_permutation ({x + 1, y + 2, z + 3}); +@c ===end=== +@example +(%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] +@end example + +@end deffn + @anchor{rreduce} @deffn {Function} rreduce (@var{F}, @var{s}) @deffnx {Function} rreduce (@var{F}, @var{s}, @var{s_@{n + 1@}}) |