Skip to content

Instantly share code, notes, and snippets.

Created September 21, 2010 18:40
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 anonymous/590253 to your computer and use it in GitHub Desktop.
Save anonymous/590253 to your computer and use it in GitHub Desktop.
pmichaud@plum:~/parrot/trunk$ cat fib.nqp
#! nqp
sub fib($n) {
$n < 2 ?? $n !! fib($n-1) + fib($n - 2);
}
my $N := 29;
my $t0 := pir::time__N();
my $z := fib($N);
my $t1 := pir::time__N();
pir::say("fib($N) = " ~ fib($N));
pir::say("time = " ~ ($t1-$t0));
pmichaud@plum:~/parrot/trunk$ ./parrot-nqp --target=pir fib.nqp >fib.pir
pmichaud@plum:~/parrot/trunk$ ./parrot fib.pir
fib(29) = 514229
time = 3.43642902374268
pmichaud@plum:~/parrot/trunk$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment