[erlang-questions] lists:filter/2

Robert Virding <>
Sun Jan 13 23:29:03 CET 2008


Yes,

robert

On 11/01/2008, Dominic Williams <> wrote:
>
> Hi Doug,
>
> > Does lists:filter(Pred, List1) -> List2
> >
> > guarantee to return the filtered items in List2
> > in the same relative order as unfiltered List1?
>
> If you check the code of lists.erl, you'll find filter/2 is
> implemented using a list comprehension:
>
> filter(Pred, List) when is_function(Pred, 1) ->
>      [ E || E <- List, Pred(E) ].
>
> List comprehensions definitely preserve order.
>
> Regards,
>
> Dominic Williams
> http://dominicwilliams.net
>
> ----
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080113/2df67401/attachment.html>


More information about the erlang-questions mailing list