[erlang-questions] Why lists:dropwhile() didn't return the expected result?

catsunny catsunny@REDACTED
Thu May 1 12:42:39 CEST 2008


Hello,
Hope I am not ask silly questions. I am new to erlang. So it's probably my  
mistake.
The following is what I did:

13> K=fun
13>     (X) when X>4 ->
13>          true;
13>     (X) when X==4 ->
13>          true;
13>     (X) when X<4 ->
13>          false
13> end
13> .
#Fun<erl_eval.6.13229925>
14> lists:dropwhile(K,[1,2,3,4,5,6,7,8]).
[1,2,3,4,5,6,7,8]
15> K(1).
false
16> K(55).
true

At prompt line 14, I hope the return value to be [1,2,3], but it's  
[1,2,3,4,5,6,7,8]. Why?

Thanks.
Catsunny
2008-05-01



More information about the erlang-questions mailing list