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

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;

# vim: expandtab shiftwidth=4 ft=perl6

See Also

100-doors.pl

100 Doors

24-game.pl

24 game

accumulator-factory.pl

Accumulator factory

arbitrary-precision-integers.pl

Arbitrary-precision integers (included)

balanced-brackets.pl

Balanced brackets

binomial-coefficient.pl

Binomial Coefficient

copy-a-string.pl

Copy a string

create-a-two-dimensional-array-at-runtime.pl

Create a two-dimensional array at runtime

hailstone-sequence.pl

Hailstone sequence

last-fridays-of-year.pl

Last fridays of the year

prime-decomposition.pl

Prime decomposition

README.md

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.