2010-02-08

More hails

A much more recent pattern matching language is Perl, so for the sake of comparison, here is the Hailstone program in Perl:

for ($i = @ARGV[0];
print("$i\n"), $i > 1;
$i = $i % 2 ? $i * 3 + 1 : $i / 2) { };

(This is really a one-liner, but I've broken it over three lines to fit the text width.)

No comments: