erlang example from book:Programming Erlang