[erlang-questions] lists:takewhile and lists:splitwith

Richard O'Keefe ok@REDACTED
Thu Feb 3 22:34:59 CET 2011


On 3/02/2011, at 11:06 PM, Joseph Wayne Norton wrote:

> 
> Try the following ...
> 
> 5> lists:partition(fun(A)-> A<3 end,[1,2,3,4,5]).
> {[1,2],[3,4,5]}


For this example, all of

   lists:partition(fun (A) -> A < 3 end, [1,2,3,4,5])

   lists:splitwith(fun (A) -> A < 3 end, [1,2,3,4,5])

   lists:splitwith(fun (A) -> A/= 3 end, [1,2,3,4,5])

give the same answer.  It is only when the list is sorted
that this is so.  None of them uses the fun that the
OP wished to use.  



More information about the erlang-questions mailing list