Skip to content

Instantly share code, notes, and snippets.

@mrkaspa
Created May 27, 2015 21:05
Show Gist options
  • Save mrkaspa/c50a81c14f4a05c1b8fb to your computer and use it in GitHub Desktop.
Save mrkaspa/c50a81c14f4a05c1b8fb to your computer and use it in GitHub Desktop.
Tail recursion con bilby
bilby = require('bilby')
loop1 = (n) ->
inner = (acc, i) ->
if(i is 0)
bilby.done(acc)
else
bilby.cont( ->
inner(acc + i, i - 1)
)
bilby.trampoline(inner(0, n))
console.log loop1(25000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment