langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,17 @@
# This is a rather obscure technique to have an anonymous
# function call itself.
fibonacci = (n) ->
throw "Argument cannot be negative" if n < 0
do (n) ->
return n if n <= 1
arguments.callee(n-2) + arguments.callee(n-1)
# Since it's pretty lightweight to assign an anonymous
# function to a local variable, the idiom below might be
# more preferred.
fibonacci2 = (n) ->
throw "Argument cannot be negative" if n < 0
recurse = (n) ->
return n if n <= 1
recurse(n-2) + recurse(n-1)
recurse(n)