▲ | eru 5 days ago | ||||||||||||||||||||||||||||||||||
Loops are a special case of tail recursion which is a special case of recursion [0] which is a special case of calling functions. However, loops aren't the only use for tail recursion. Another classic example are state machines as described in the 'Lambda: the ultimate goto' paper. See eg https://en.wikisource.org/wiki/Lambda:_The_Ultimate_GOTO [0] Well, recursion on functions. You can also have eg recursive data types or recursion in mathematics in general. But let's focus on functions. | |||||||||||||||||||||||||||||||||||
▲ | Kranar 5 days ago | parent [-] | ||||||||||||||||||||||||||||||||||
I think it's the other way around. Tail recursion is a special case of loops. All tail recursive functions can be rewritten as a loop but there exist loops that can not be rewritten as a tail recursive function. | |||||||||||||||||||||||||||||||||||
|