12:23a27ec9f362
Anton Shestakov <engored@ya.ru>, Wed, 26 Feb 2014 02:28:07 +0900
A bit more consistent naming in rps3.

next change 13:30f6287441d2
previous change 9:4b4d65b99174

rps3.erl

Permissions: -rw-r--r--

Other formats: Feeds:
-module(rps3).
-export([get_rules/0, beats/1, test_beats/0]).
get_rules() -> [rock, paper, scissors].
beats(H) ->
beats(H, get_rules()).
beats(H, [H|Tail]) ->
lists:last(Tail);
beats(H, [B,H|_]) ->
B;
beats(H, [_|T]) ->
beats(H, T).
test_beats() ->
lists:foreach(
fun(C) ->
io:format("~w beats ~w.~n", [C, beats(C)])
end,
get_rules()).