Example code from the book Erlang Programming