Storing state in Erlang with processes (2014)

Storing state in Erlang with processes (2014)

Here is an example of a counter in erlang that prints out the value as it increments with each recursive function call. In the previous section we created a counter that increments its own value by calling itself recursively, but we had no way to control the counter or access its state from any external code. When we call , the function spawns a new recursive loop with a zero initial counter value and returns the pid of the spawned process.

Source: dantswain.herokuapp.com