>>>>> "JP" == John Porter <jdporter@min.net> writes: JP> Uri wrote: >> >> 13,4R52?52 >> >> R is rho, the matrix size and reshape operator. this dealt a 52 card >> hand (? is the random and deal operator) and reshaped it to 4 hands of >> 13 cards. JP> Does it actually *deal*? my apl is corroded so i can't answer. i was able to get 1 .. 52 in a random order very easily. i52 (i is iota) is 1 .. 52. that might be missing and then passed to 52? (but as i say i don't recall apl well). but what do you mean by deal? shuffling 1 .. 52 is a deal in my book. the numbers are unique and in random order. JP> If the randomization is good, you don't need to deal; so you can do this JP> in perl: JP> $hands[$_] = splice @shuffled, 0, 13 for 0..3; that doesn't work as you are assigning a list to a scalar. you need an anon array there. and why do a splice when a slice will do? @deck = ( 1 .. 52 ) ; $card = rand @deck, ( $deck[$card], $deck[$_] ) = ( $deck[$_], $deck[$card] ) for 0 .. $#deck ; could i save on the card assignment? i don't trust execution ordering. @hands = map [ @deck[ ( $_ * 13 ) .. ( $_ * 13 + 12 ) ] ], 0 .. 3 ; print map "@{$hands[$_]}\n", 0 .. 3 ; or if you don't mind (or you prefer) a destructive splice: push( @hands, [ splice( @deck, 0, 13 ) ] ) for 0 .. 3; push( @hands, [ splice( @deck, 0, 13 ) ] ) while @deck ; push( @hands, [ splice( @deck, -13 ) ] ) while @deck ; @hands = map [ splice( @deck, -13 ) ], 0 .. 3 ; you get the picture. uri -- Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting Have Perl, Will Travel ----------------------------- http://www.sysarch.com The Best Search Engine on the Net ------------- http://www.northernlight.com "F**king Windows 98", said the general in South Park before shooting Bill. ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe