edubkendo
9/26/2014 - 3:37 AM

Cooler elixir stack: Now with push

Cooler elixir stack: Now with push

defmodule Stack.Server do
  use GenServer

  def handle_call(:pop, _from, stack) do
    [ head | tail] = stack
    { :reply, head, tail }
  end

  def handle_cast({:push, data_to_push}, stack) do
    { :noreply, [ data_to_push | stack ] }
  end
end