Skip to content

Instantly share code, notes, and snippets.

@andresteingress
Created October 9, 2013 17:40
Show Gist options
  • Save andresteingress/6905156 to your computer and use it in GitHub Desktop.
Save andresteingress/6905156 to your computer and use it in GitHub Desktop.
Groovy Continuations
def factorial
factorial = { n, c ->
if (n == 1)
c(1)
else
factorial(n - 1, { m -> c(n * m) })
}
def result = null
factorial(4, { x -> result = x })
println result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment