[erlang-questions] How to pass the length of binary to match into a function that matches the binary?

Younès HAFRI irfah.senuoy@REDACTED
Mon Nov 24 14:24:53 CET 2014


 my_fun(Len, Bin) ->
    fun (<<Head:Len/binary, Rest/binary>>) ->
            ...
        (_) ->
            ...
    end(Bin).

Le lundi 24 novembre 2014, Imants Cekusins <imantc@REDACTED> a écrit :

> Would this work:
>
> my_fun(<<Bin:8/binary, Rest/binary>>) -> ok;
>
> my_fun(<<Bin:16/binary, Rest/binary>>) -> ok.
>
> ?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20141124/a92995c5/attachment.htm>


More information about the erlang-questions mailing list