Ackermann function

Author: Filip Sergot

The Ackermann function is a classic recursive example in computer science.

More

http://rosettacode.org/wiki/Ackermann_function#Raku

What's interesting here?

  • ternary chaining

  • recursive functions

Features used

Source code: ackermann-function.pl

use v6;

sub A(Int $m, Int $n) {

    $m == 0  ??    $n + 1                   !!
    $n == 0  ??  A($m - 1, 1            )   !!
                 A($m - 1, A($m, $n - 1));

}
A(1, 2).say;