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
ternary operator
- http://doc.perl6.org/language/operators#infix_%3F%3F_%21%21multi subs
- http://doc.perl6.org/syntax/multi
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;