Amir wrote: > > > From: Brand Hilton <bhilton@adc.com> > > use Algorithms::Numerical::Shuffle; > > @cards = (0 .. 51); # or any number of them > > @cards = shuffle(@cards) > > Abigail indeed uses the (non-clobbering) N-swaps method, adding in the > ability to handle ref'ed arrays in place (no memory overhead) or regular > arrays. I suppose that's why Abigail is a Perl Somebody. Well, considering this algorithm is a standard from Way Back, known as the Fisher/Yates algorithm, anyone could have made a module out of it. Abigail just happened to get to it first. > > From: Chip Turner <chip@zfx.com> > > > > @a = (rand(@cards) % @cards, $_ % @cards), @cards[@a] = @cards[reverse @a] > > foreach 0 .. ($passes * @cards - 1); > > Btw, save bytes by not taking %cards for rand(@cards), which certainly gives > you a number from 0..@cards. Let's be precise: it gives a floating point number in the interval [ 0 .. @cards ). Which may or may not be what you want. John Porter ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe