     last_val
   end
 
+  def compute([], [], _) do
+    # just bail
+  end
+
+  def compute([ "end" | _ ], stack, _) do
+    if Enum.count(stack) == 1 do
+      List.first(stack)
+    else
+      stack
+    end
+  end
+
   def compute([ "+" | remaining_input], [y, x | stack], dict) do
     compute(remaining_input, [x + y | stack], dict)
   end

  # Usage: test_val is on top of stack. "if <then-clause> else <else-clause> then"
  # puts then-clause on top of instruction stack if test_val != 0, else-clause if test_val == 0.
  def compute([ "if" | remaining_input], [x | stack], dict) do
    {if_clause, ["else" | remaining_input]} = Enum.split_while(remaining_input, fn(ins) -> ins != "else" end)
    {else_clause, ["then" | remaining_input]} = Enum.split_while(remaining_input, fn(ins) -> ins != "then" end)
    if x != 0 do
      compute(if_clause ++ remaining_input, stack, dict)
    else


  defmodule RPNForthThingTest do
    use ExUnit.Case, async: true

    import ExUnit.CaptureIO

    test "normalizing input list" do
      assert RPNForthThing.normalize(["1", "5", "+"]) === [1, 5, "+"]
