Skip to content

Instantly share code, notes, and snippets.

@bsideup
Last active August 29, 2015 14:14
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 bsideup/21fc363a3fa880d1d0a4 to your computer and use it in GitHub Desktop.
Save bsideup/21fc363a3fa880d1d0a4 to your computer and use it in GitHub Desktop.
def fact(num) {
return match(num) {
String >> fact(num.toInteger())
(0 | 1) >> 1
2 >> 2
_ >> _ * fact(_ - 1)
}
}
assert fact("5") == 120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment