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

Joseph Wayne Norton norton@REDACTED
Thu Feb 3 11:06:30 CET 2011


Try the following ...

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

On Thu, 03 Feb 2011 18:56:14 +0900, maruthavanan s  
<maruthavanan_s@REDACTED> wrote:

>
> Hi,
>
> The document says lists:takewhile(Pred,List) would return tuple of lists  
> which would split the List when Pred returns true.
>
> I tried the below.
>
>  lists:takewhile(fun(A)-> A==3 end,[1,2,3,4,5]).
>
> it gives me an empty result.. What should I do to  get {[1,2],[3,4,5]}
>
> Regards,
> Marutha
>  		 	   		


-- 
norton@REDACTED


More information about the erlang-questions mailing list