Archive for March 30, 2011
Introduction to Erlang : Recursion (1/2)
Recursion
The definition of the word recursion is “(mathematics) an expression such that each term is generated by repeating a particular mathematical operation”, according to the WordNet. Recursion is one of the most powerful “tools” in a functional programming language and so it is for Erlang. Recursion can be used to apply divide and conquer techniques to problem solving, where a problem is broken to smaller subproblems, the subproblems are solved, and the results are “merged” to generate the final result.
Recursion happens when a function’s body definition includes a call to the function itself.
functionA(...) -> Body_before_recursion, % optional functionA(...), Body_after_recursion. % optional |
Recursion is used instead of the conventional loop statements of other programming languages, such as while
and for
in C.
Read the rest of this entry »