in reply to Ackerman vs. Perl : KO in 3 rounds
The hackery with the short-circuit sub calls is part of the problem. If I rewrite this in a "naive" way:
I get a reasonable answer with (3,3). However, on (4,4), I get "Not a CODE reference at a.pl line 7" followed by a memory fault. (I'm using 5.6.1 on HP-UX, BTW.)sub A { my ($m, $n) = @_; return 0 if $n == 0; return 2*$n if $n > 0 and $m == 0; return 2 if $n == 1 and $m > 0; A($m-1, A($m, $n-1)); } print A ($ARGV[0], $ARGV[1]), "\n";
|
|---|