Skip to content

Instantly share code, notes, and snippets.

@retokromer
Created December 20, 2015 11:01
Show Gist options
  • Save retokromer/78923b34fd9f1e584088 to your computer and use it in GitHub Desktop.
Save retokromer/78923b34fd9f1e584088 to your computer and use it in GitHub Desktop.
Some more Perl 6 testing.
use v6;
say 'Ackermann function: A(m,n)';
print 'Enter m = ';
my $M = $*IN.get;
print 'Enter n = ';
my $N = $*IN.get;
sub A($m, $n) {
$m == 0 ?? $n + 1 !!
$n == 0 ?? A($m - 1, 1 ) !!
A($m - 1, A($m, $n - 1));
}
A($M, $N).say;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment