   def compute([ "(" | remaining_input ], stack, dict) do
     {_, [")" | remainder]} = Enum.split_while(remaining_input, fn(ins) -> ins != ")" end)
     compute(remainder, stack, dict)
+  end
+
+  # Do loops
+  def compute([ "do" | remainder ], [x, y | stack], dict) do
+    {the_loop, ["loop" | remainder]} = Enum.split_while(remainder, fn(ins) -> ins != "loop" end)
+    # So the forth spec says the do loop goes up to but NOT INCLUDING the last number
+    # But in my case the first number can be bigger than the last, so it counts down
+    # Call it an enhancement
+    # But that means we have to increment or decrement appropriately based on which is bigger.
+    end_num = if x < y, do: y-1, else: y+1
+    unrolled_loop = Enum.map x..end_num, fn i ->
+      # replace each "i" in the loop context with the index value
+      Enum.map(the_loop, fn(maybe_i) -> if maybe_i == "i", do: i, else: maybe_i end)
+    end
+    compute(List.flatten([unrolled_loop | remainder]), stack, dict)
   end
 
   # new definitions!

  # 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

      # Well holy shit, it passes.
    end

    test "emit" do
      assert capture_io(fn ->
        RPNForthThing.initialize(~w[ 101 emit ])
      end) == "e"
    end

    test "carriage return" do
      assert capture_io(fn ->
        RPNForthThing.initialize(~w[ cr end ])
      end) == "\n"
    end

    test "emit looped numbers" do
      assert capture_io(fn ->
        RPNForthThing.initialize(~w[ 0 10 do i emit loop ])
      end) == <<10, 9, 8, 7, 6, 5, 4, 3, 2, 1>>
    end

    test "print stars" do
      # example from https://github.com/dsevilla/uForth
      assert capture_io(fn ->
        RPNForthThing.initialize(~w[
          : STAR 42 emit ;
          : STARS 0 do STAR loop ;
          20 STARS end
        ])
      end) == "********************"
    end

  end
else
  IO.puts RPNForthThing.initialize
