Executing boolean expressions on a list
Fri Mar 14 03:39:13 CET 2003
625 all(Pred, [Hd|Tail]) ->
626 case Pred(Hd) of
627 true -> all(Pred, Tail);
628 false -> false
630 all(_, ) -> true.
It would seem that the Erlang masters implemented it exactly
as I have. At these few points in my code, I'd rather not
do the remote function call + fun call, but lists:all/2 does
what I want. :-)
Maybe I'll change my code. Thanks Peter.
Peter H|gfeldt <peter@REDACTED> wrote:
> How about lists:all/2,
> recursive(N, Es) ->
> lists:all(fun(E) -> somef(N, E) end, Es) ?
> On Thu, 13 Mar 2003, Shawn Pearce wrote:
> > I find I'm writing a lot of:
> > recursive(N, [H | T]) ->
> > case somef(N, H) of
> > true -> recursive(N, T);
> > false -> false
> > end;
> > recursive(N, ) ->
> > true.
> > somef(N, E) ->
> > .... % return true or false.
The human race is a race of cowards; and I am not only marching in that
procession but carrying a banner.
-- Mark Twain
More information about the erlang-questions