Skip to content

Instantly share code, notes, and snippets.

@villadora
Created January 7, 2013 09:09
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 villadora/4473535 to your computer and use it in GitHub Desktop.
Save villadora/4473535 to your computer and use it in GitHub Desktop.
tail recursion

In traditional recursion, the typical model is that recursive calls are performed first, and then take the return value of the recursive call and calculate the result. In this manner, you don't get the result of calculation until you have returned from every recursive call.

In tail recursion, calculations are performed first, and then execute the recursive call, passing the results of current step to the next recursive step. The last statement is formed like"(return (recursive-function params))"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment