By Letter: Non-alphabet | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
  Email this page to a friend


Tail recursion




<programming> When the last thing a function (or procedure) does is to call itself.

Such a function is called tail recursive.

A function may make several recursive calls but a call is only tail-recursive if the caller returns immediately after it.

E.g.

f n = if n < 2 then 1 else f (f (n-2) + 1)

Here the both calls to fib are recursive but only the outer one is tail recursive.

See tail recursion optimisation, and, if you aren't sick of them already, recursion, tail recursion.

[Jargon File]



< Previous Terms Terms Containing tail recursion Next Terms >
Tagged Image File Format
tagged queueing
tagged types
tag name
tail circuit
conversion to iteration
Id Nouveau
last call optimisation
recursion
tail recursion
tail recursion modulo cons
tail recursion optimisation
tail-strict
TAL
TALE


Web Standards & Support:

Link to and support eLook.org Powered by LoadedWeb Web Hosting
Valid XHTML 1.0!Valid CSS!eLook.org FireFox Extensions