Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

masak (6289)

masak
  (email not shown publicly)
http://masak.org/carl

Been programming Perl since 2001. Found Perl 6 somewhere around 2004, and fell in love. Now developing November (a Perl 6 wiki), Druid (a Perl 6 board game), pls (a Perl 6 project installer), GGE (a regex engine), and Yapsi (a Perl 6 implementation). Heavy user of and irregular committer to Rakudo.

Journal of masak (6289)

Friday November 27, 2009
05:58 PM

November 27 2009 -- straight towards the surface

[ #39956 ]

38 years ago today, the Mars 2 orbiter releases a descent module towards the surface of Mars.

The descent module separated from the orbiter on 27 November 1971 about 4.5 hours before reaching Mars. After entering the atmosphere at approximately 6 km/s, the descent system on the module malfunctioned, possibly because the angle of entry was too steep. The descent sequence did not operate as planned and the parachute did not deploy. Mars 2 was the first manmade object to reach the surface of Mars. The landing site is unknown.

Mars 3, practically at the coat-tails of its sibling, made a descent a few days later, and landed softly.

Today I wrote a toy script, which might get integrated into the Perl 6 book we're writing.

The script shuffles a full deck of cards, draws two hands from it, and compares them. Could easily be extended into a full-fledged poker game. Here it is.

Writing it was remarkably fun, and it shook out a couple rakudobugs.

Look carefully at the use of where clauses in the script. We found out on the channel that where clauses are much more powerful than any of us had realized until now. Here are a few of the more beautiful ones:

subset FullHouse of PokerHand where OnePair & ThreeOfAKind;

subset Flush of PokerHand where -> @cards { [==] @cards>>.suit }

subset StraightFlush of Flush where Straight;

I originally had that last one as Straight where Flush, but I think the Flush computation is faster, so I put that one first, according to some fail-fast principle.

The script also raised the question "how does one get all the values of an enum", and TimToady gave the tentative answer SomeEnum::.keys, but this does not work in Rakudo yet.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.