Category:Recursion: Difference between revisions
Content added Content deleted
m (Grammar fix) |
m (formatting) |
||
Line 3: | Line 3: | ||
A pseudocode function to demonstrate recursion would look something like this: |
A pseudocode function to demonstrate recursion would look something like this: |
||
function F with arguments |
'''function''' F '''with''' arguments |
||
'''if''' ''end condition is not met'' |
|||
'''return''' ''F called with new set of arguments'' |
|||
'''else''' |
|||
'''return''' ''end condition value'' |
|||
More than one end condition is allowed. More than one recursion condition is allowed. |
More than one end condition is allowed. More than one recursion condition is allowed. |
||
Line 21: | Line 21: | ||
Sometimes, tail-recursive functions are coded in a way that makes them not tail-recursive. The example above could become tail-recursive if it were transformed to look like this: |
Sometimes, tail-recursive functions are coded in a way that makes them not tail-recursive. The example above could become tail-recursive if it were transformed to look like this: |
||
'''function''' F '''with''' arguments |
|||
if end condition is met |
'''if''' ''end condition is met'' |
||
return end condition value |
'''return''' ''end condition value'' |
||
else |
'''else''' |
||
return F called with new set of arguments |
'''return''' ''F called with new set of arguments'' |
||
Below is a list of examples of recursion in computing. |
Below is a list of examples of recursion in computing. |