Code from the book "Learn You Some Erlang For Great Good!"