Do you know the Knuth's "man or boy" test ?
If not, see http://en.wikipedia.org/wiki/Man_or_boy_test
that contains explanations and implementations in various languages.
A Perl5 implementation is :
sub A {
my ($k, $x1, $x2, $x3, $x4, $x5) = @_;
my $B;
$B = sub {
return A(--$k, $B, $x1, $x2, $x3, $x4);
};
return &$x4() + &$x5() if ($k <= 0);
return &$B();
}
print A(10, sub{1}, sub{-1}, sub{-1}, sub{1}, sub{0}), "\n";
# the expected result is -67
In r32377, I commit a Lua implementation that works on Parrot.
Can we do a Perl6 implementation with the current Rakudo ?
François.
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev