A solution to exercises at the end of Chapter 22 in Programming Erlang 2/ed by Joe Armstrong