develooper Front page | perl.perl6.language | Postings from May 2005

Reductions, junctions, hashslices, and cribbage scoring

Thread Next
From:
Rob Kinyon
Date:
May 25, 2005 10:30
Subject:
Reductions, junctions, hashslices, and cribbage scoring
Message ID:
703844205052510294bfa6099@mail.gmail.com
(This post references the discussion at
http://www.perlmonks.org/?node_id=458728, particularly dragonchild's
response at the bottom.)

For those who don't know, cribbage is a game where each player has
access to 4 cards, plus a community card. Various card combinations
score points. The one in question is when cards add up to 15. If you
have a group of cards that add up to 15, you receive 2 points. This is
for every group, so if you have a ten and 2 fives, you get 4 points.
Two tens and two fives is 8 points. Face cards are worth 10 and aces
are 1, for these purposes.

I proposed the following:

# Fifteens
$score += 2 * all( 15 == [+]@hand{ any( 0 .. 4 ) } );

* Is this syntax legal?
* Does it do what I want it to do?
* Is there another way?

Thanks,
Rob

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About