[erlang-questions] Weird lists:dropwhile/2 behavior?

fxmy wang <>
Sun Feb 21 14:40:50 CET 2016


Thanks guys, somehow the doc gives me a feeling that lists:dropwhile will
scan through all the list no matter Pred(Elem) returns 'true' or 'false'. =)

Cheers

2016-02-21 21:36 GMT+08:00 Jesper Louis Andersen <
>:

>
> On Sun, Feb 21, 2016 at 1:39 PM, fxmy wang <> wrote:
>
>> Is this behavior expected?
>
>
> yes. To make it explicit:
>
> In lists:dropwhile(fun(E) -> E > 3 end, [1,2,3,4,5]), we first check if 1
> > 3. This is false, so we stop dropping and return the remainder of the
> list, which is [1,2,3,4,5].
>
>
> --
> J.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160221/adf0437f/attachment.html>


More information about the erlang-questions mailing list