package Math::Ackermann; use strict; use vars qw($VERSION @ISA); require Exporter; require DynaLoader; @ISA = qw(Exporter DynaLoader); $VERSION = '1.00'; bootstrap Math::Ackermann $VERSION; sub new { my $class = shift; bless [], $class } sub compute { my($ackermann, $m, $n) = @_; defined $ackermann->[$m][$n] or $ackermann->[$m][$n] = A($m, $n); $ackermann->[$m][$n]; } 1 __END__ =head1 NAME Math::Ackermann - Computes and caches Ackerman's function =head1 SYNOPSIS use Math::Ackermann; $ackermann = new Math::Ackermann; $x = $ackerman->compute($m, $n); =head1 DESCRIPTION Comptutes Ackermann's function, defined recursively as A(0 , n ) = n + 1 A(m+1, 0 ) = A(m, 1) A(m+1, n+1) = A(m, A(m+1, n)) This is an B CPU-intensive function. Values are cached as they are computed. Subsequent calls with the same arguments return the cached value. =head1 AUTHOR Steven McDougall, swmcd@world.std.com =head1 SEE ALSO perl(1) http://public.logica.com/%7Estepneys/cyc/a/ackermnn.htm =cut