[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Perfect single shuffle



Here's a sub that does a perfect single shuffle:

sub shuffle { @_[map $_&1 ? $_>>1 : ($_>>1)+($#_>>1), 1..@_] }

Note that it is actually useful for something:

$hashref = { shuffle(@keys, @values) }

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe