[erlang-bugs] lists:dropwhile

Matt Handler matt.handler@REDACTED
Fri Jun 13 15:55:53 CEST 2008


dropwhile does not work properly as defined in R12B-2:

01 dropwhile(Pred, [Hd|Tail]=Rest) ->
02    case Pred(Hd) of
03       true -> dropwhile(Pred, Tail);
04       false -> Rest
05    end;
06 dropwhile(Pred, []) when is_function(Pred, 1) -> [].

it returns the entire list once it finds an element that doesn't match true.

here's what i did instead:

dropwhile(Fun, List) ->
    [Element ||
    Element <- List,
    Fun(Element) =/= true].

thanks,
-matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20080613/83ada164/attachment.htm>


More information about the erlang-bugs mailing list