To name a function

Attila Rajmund Nohl attila.r.nohl@REDACTED
Wed Dec 15 17:06:54 CET 2010


I've found at least places in my code where I'd need a function which
decides if all, some or none members of a list have a particular
property (the list always has at least one element). How to name this
function? The code is something like this:

f(_F, []) ->
  erlang:error({badarg, []});

f(F, L) ->
  {Has, Not} =
      fun(E, {H, N}) ->
        case f(E) of
          true -> {H+1, N};
          false -> {H, N+1}
      end, {0,0}, L),
  case {Has, Not} of
    {0, _} -> none;
    {_, 0} -> all;
    _ -> some

More information about the erlang-questions mailing list