Skip to content

Instantly share code, notes, and snippets.

@marcoonroad
Created October 16, 2014 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcoonroad/7b8710112d4da3301e85 to your computer and use it in GitHub Desktop.
Save marcoonroad/7b8710112d4da3301e85 to your computer and use it in GitHub Desktop.
Fibonacci using multi-dispatch functions at Perl 6...
#!/usr/bin/perl6
use v6;
multi fib(Int $n where -> $n { $n ~~ any(1, 2) }) { 1 }
multi fib(Int $n where -> $n { $n > 2 }) { fib($n - 1) + fib($n - 2) }
say fib 10; # 55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment