Created
December 31, 2009 20:09
-
-
Save ELLIOTTCABLE/266886 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fib ↼ routine { | |
if { @ x =(0) |(@ x =(1)) } { @ last(1) } { | |
@ last( callee(@ 1 -(1), ?) +(callee(@ 1 -(2), ?))) }} | |
fib(5) { print(@) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fib ↼ routine | |
if { @x = 0 | @x = 1 } { @last(1) } | |
@last(callee(@1 - 1, ?) + callee(@1 - 2, ?)) | |
fib(5) { print(@) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With macros (libside sugar)
func fib(n)
if(n == 0 || n == 1)
out n
out fib(n - 1) + fib(n - 2)
Without any libside sugar
fib =
native tools if(@0 == 0 || @0 == 1)
return = @0
return = fib(@0 - 1) + fib(@0 - 2)