Anton Shestakov <engored@ya.ru>, Mon, 03 Mar 2014 19:46:02 +0900
Make rps3 a gen_server under the hood.
src/rps5.erl
Permissions: -rw-r--r--
winning_hand/1, test_winning_hand/0]). get_hands() -> [rock, paper, scissors, spock, lizard]. io:format("~w beats ~w.~n", [H, beats(H)]) io:format("~w loses to ~w.~n", [H, loses(H)]) % rock, rock, rock -> rock % rock, paper, scissors -> undefined % rock, paper, paper -> paper % rock, rock, paper -> paper HSet = sets:from_list(Hands), case sets:is_disjoint(sets:from_list(Loses), HSet) of Exclude = fun(Hand) -> lists:delete(Hand, get_hands()) end, |lists:map(Exclude, get_hands()) Winner = winning_hand(Hands), io:format("~w wins in ~w.~n", [Winner, Hands])