in reply to The Ackermann Function

The following is perldiag's description of this warning:

This subroutine has called itself (directly or indirectly) 100 times more than it has returned. This probably indicates an infinite recursion, unless you're writing strange benchmark programs, in which case it indicates something else.

If the deep recursion is expected — it is — you can remove the warning using no warnings 'recursion';

To speed things up (by omitting redundant calls) at the expense of memory, use Memoize to cache results.

By the way, your @ARGV code can be simplified to:

my $m = shift || 0; my $n = shift || 0;

Replies are listed 'Best First'.
Re^2: The Ackermann Function
by ikegami (Patriarch) on Jun 20, 2006 at 19:01 UTC

    The results of memoizing (without actually using Memoize) are:

    ackermann(0..3, 4) swampyankee: ok ikegami: ok Benchmark: timing 1000 iterations of ikegami, swampyankee... ikegami: 6 wallclock secs ( 4.54 usr + 0.00 sys = 4.54 CPU) @ 22 +0.46/s (n=1000) swampyankee: 49 wallclock secs (35.96 usr + 0.02 sys = 35.98 CPU) @ 2 +7.79/s (n=1000) Rate swampyankee ikegami swampyankee 26.8/s -- -88% ikegami 220/s 724% --

    Code: