Skip to content

Instantly share code, notes, and snippets.

@timo
Created February 28, 2012 14:48
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 timo/1932925 to your computer and use it in GitHub Desktop.
Save timo/1932925 to your computer and use it in GitHub Desktop.
perl6ish fibonacci
# vi: ft=perl6
use v6;
sub fib(Int $x) {
constant @fib_list = 0, 1, * + * ... *;
die "non-negative arguments required"
unless $x >= 0;
@fib_list[$x];
}
sub MAIN(Int $fib) {
say fib($fib)
}
@timo
Copy link
Author

timo commented Mar 14, 2012

thanks to @colomon for the obvious solution with the sequence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment