Created
September 26, 2014 03:37
-
-
Save edubkendo/2affb87911916e96d598 to your computer and use it in GitHub Desktop.
Cooler elixir stack: Now with push
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Author
edubkendo
commented
Sep 26, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment