Fun with lists



>Hi Jaime!

> (%i3) list_shuffle(l) := block([r], for n:length(l) step -1 thru 2
>  do (r:random(n), l:endcons(part(l,r+1),list_remove(l,r+1,1))), l)$

I think, for lists, random_permutation does just the desired thing:

random_permutation([a,b,c,d,e,f,g]);

For any Operator, here a alternative solution in functional style:
(very short)

list_shuffle(f):=apply(op(f),random_permutation(args(f)));

Regards,
Wilhelm Haager