--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rps5.erl Wed Feb 26 19:05:32 2014 +0900
+ winning_hand/1, test_winning_hand/0]).
+get_rules() -> [rock, paper, scissors, spock, lizard].
+ io:format("~w beats ~w.~n", [H, beats(H)])
+ io:format("~w loses to ~w.~n", [H, loses(H)])
+% winner for 3 hands is:
+% 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_rules()) end,
+ [rock, paper, scissors],
+ |lists:map(Exclude, get_rules())
+ Winner = winning_hand(Hands),
+ io:format("~w wins in ~w.~n", [Winner, Hands])