[erlang-questions] binary_comprehension support

Vlad Dumitrescu vladdu55@REDACTED
Tue May 29 08:35:01 CEST 2007


Hi!

On 5/29/07, Matthew O'Gorman <mogorman@REDACTED> wrote:
> -module(test).
> -compile([export_all, binary_comprehension]).
>
> foo(Bin) -> [ X || <<X:8>> <- Bin].
>
> (mog@REDACTED)9> test:foo(<<1:8, 2:8>>).

In this particular example, you might want to write something like

foo(Bin) -> [ X || <<X:8, _/binary>> <- Bin].

because your code will only match a binary with one element.

best regards,
Vlad



More information about the erlang-questions mailing list