Skip to content

Instantly share code, notes, and snippets.

@johntyree
Created April 29, 2011 16:28
Show Gist options
  • Save johntyree/948570 to your computer and use it in GitHub Desktop.
Save johntyree/948570 to your computer and use it in GitHub Desktop.
-module(kitchen).
-compile(export_all). %% Probably replace with -export([funcs])
-author("John Tyree").
fridge2(FoodList) ->
receive
{From, show} ->
From ! {self(), FoodList},
fridge2(FoodList);
{From, {store, Food}} ->
From ! {self(), ok},
fridge2([Food|FoodList]);
{From, {take, Food}} ->
case lists:member(Food, FoodList) of
true ->
From ! {ok, Food},
fridge2(lists:delete(Food,FoodList));
false ->
From ! {self(), not_found},
fridge2(FoodList)
end;
terminate ->
ok
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment