This example was taken from book 'Introducing Erlang'. I do respect copyright and admit the ownership.