Subscribe now

Elixir Weekly Drip #3 and Exercise: Supervised RPN Calculator and Tape Printer [03.10.2017]

This week we crammed in a lot of OTP learning. To reinforce that work, we'll rebuild the RPN calculator from last week using GenServer, and add a Tape Printer to output the calculation as we go along. First, though, let's see some interesting links for the week.


This week we'll rebuild the RPN calculator from last week, using GenServer.

  • You should make the same tests pass, but with a GenServer backing it.
  • Then Supervise it so that if it crashes it gets restarted (maybe division by zero should crash it?).
  • Finally, add a Tape Printer GenServer as a dependency earlier in the Supervisor, give it a name, and have your calculator send it messages that it will print out - to a file, to the console, or wherever.
    • If you want extra work, add a feature using GenStateMachine to switch the Tape Printer into just results mode - where it only prints out reduced calculations, rather than each entry that's sent to it.