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

Re: [FWP] Perl Card Games



Uri wrote:
> 
>   >> $card = rand @deck, ( $deck[$card], $deck[$_] ) = ( $deck[$_], $deck[$card] )
>   >> for 0 .. $#deck ;
> 
> ... a quickie shuffle (the latest dance craze).

O.k., but I thought we had moved on to dealing.


>   JP> $handsize = 5; # straight poker.
>   JP> @hands = 5;    # O.k., who's in?
>   JP> @$_ = splice @deck, 0, $handsize  for @hands;  # too much fun.
> 
> again with the bugs. that will only assign the hand @5 which is very
> odd. 

Yes, I didn't pay enough attention to the second line.
I meant something more like

	@hands = () x 5;

But later I realized I could just do

	$n_hands = 5;
	@hands = map [splice @deck,0,$handsize], 1..$n_hands;

But I don't think that's as fun as 

	@$_ = (...) for @hands;

John Porter


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