Erlang LanguageLoop and Recursion


  • function ( list | iolist | tuple ) -> function( tail ).


Why recursive functions?

Erlang is a functional programming language and don't any kind of loop structure. Everything in functional programming is based on data, type and functions. If you want a loop, you need to create a function who call itself.

Traditional while or for loop in imperative and object oriented language can be represented like that in Erlang:

loop() ->
  % do something here

Good method to understand this concept is to expand all function calls. We'll see that on other examples.