Source

Learn You Some Erlang / discrep.erl

Full commit
-module(discrep).
-export([run/0]).

run() ->
    List = [1,2,3],
    Res = [compare(X) || X <- List],
    case lists:all(fun check_small/1, Res) of
        true ->
            io:format("All numbers are small!~n");
        false ->
            io:format("Not all numbers are small!~n")
    end.

compare(X) when X < 3 ->
    small;
compare(X) when X =:= 3 ->
    three;
compare(X) when X > 50 ->
    very_large;
compare(X) when X > 3 ->
    large.

check_small(small) ->
    true;
check_small(very_large) ->
    false;
check_small(large) ->
    false.