lists:partition/2

Martin Bjorklund <>
Wed Jan 17 13:47:53 CET 2001


Raimo Niskanen <> wrote:
> Hello,
> 
> I am missing function in the module lists, one that using a predicate
> partitions a list into two; one with all elements for which the
> predicate was true, and one for the rest, while preserving the ordering
> of the elements.

> The questions are: is partition/2 sucha a useful function that it is
> worthy of being included in the lists module,

yes, definitely!  i've (re)implemented it many times...

> and are there any comments on the implementation?

use the first one.  also, maybe you could add a function that doesn't
preserve the order.


/martin



More information about the erlang-questions mailing list