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

Younès HAFRI <>
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 <> 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.html>


More information about the erlang-questions mailing list