[erlang-questions] Doubt with lists:dropwhile

Farruco Sanjurjo <>
Wed Apr 25 19:34:35 CEST 2012


Hi,

I'm not getting the expected result while using lists:dropwhile/2

Here is an example of my problem:

Data = <<"HTTP/1.1 205 Reset Content\r\n
              Header-A: A\r\n
              Header-C : dGhlIHNhbXBsZSBub25jZQ==\r\n
              Header-D: D\r\n\r\n
              ">>,

lists:dropwhile(fun(E) -> E == <<>> end, binary:split(Data, <<"\r\n">>,
[trim, global])).

And this is the result:

[<<"HTTP/1.1 205 Reset Content">>,
 <<"\n              Header-A: A">>,
 <<"\n              Header-C dGhlIHNhbXBsZSBub25jZQ==">>,
 <<"\n              Header-D: D">>,<<>>,
 <<"\n              ">>]

But on the result above, there's a <<>> which if I understand the manpage
of lists:dropwhile shouldn't be there.

Am I misunderstanding something?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120425/b921a4ce/attachment.html>


More information about the erlang-questions mailing list