Reply to post: Re: Recursion

Learn you Func Prog on five minute quick!

WorBlux

Re: Recursion

"Stobb forgot to discuss one important dogma of Functional Programming: No loops, ever."

Not really, this is generally just a byproduct of maintaining pure functions. Often the compiler will optimize recursion into a GOTO, other times it builds a stack of function calls. , A while loop checks the state of some memory location, does some stuff updating at least one memory location and jumps into a goto. Using recursion or higher-order functions is a way to prove you aren't relying on state mutation, and thus certain types of reasoning about the code are guaranteed to be correct in a way you couldn't guarantee if there was a while loop capable on manipulating internal state.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Biting the hand that feeds IT © 1998–2019