defmodule Test do 

  def actor(state) do 
    receive do 
      :inc -> 
        actor(state + 1) 
      {:get, from} -> 
        send(from, state) 
        actor(state) 
    end
  end

  def make_counter(init), do: spawn(fn -> actor(init) end)

  def inc(counter), do: send(counter, :inc)

  def get_value(counter) do 
    send(counter, {:get, self()}) 
    receive do 
      state -> 
        state 
    end
  end

  def test() do 
    my_counter = make_counter(0) 
    inc(my_counter)
    c = get_value(my_counter)
  end
end