Created
July 24, 2009 11:12
-
-
Save perl6/153993 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat cards.pl | |
my @suits = < ♣ ♢ ♡ ♠ >; | |
my @ranks = 2..10, < J Q K A >; | |
# concatenate each rank with each suit (2♣ 2♢ 2♡ ... A♠) | |
my @deck = @ranks X~ @suits; | |
# build a hash of card names to point values | |
my %points = @deck Z @( (2..10, 10, 10, 10, 11) >>xx>> 4 ); | |
# shuffle the deck | |
@deck .= pick(*); | |
# grab first five cards from the deck | |
my @hand = @deck.splice(0, 5); | |
# display my hand | |
say ~@hand; | |
# tell me how many points it's worth | |
say [+] %points{@hand}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment