[erlang-questions] How to convert a binary to a list of 2 byte ints

Ivan Uemlianin ivan@REDACTED
Thu May 27 13:15:43 CEST 2010


Dear Gleb

That is fantastic, thanks!

I had tried it with bitstring comprehensions but to no avail.  Here you 
are using the bitstring generator <= in a list comprehension.  Cool!

Best wishes

Ivan

On 27/05/2010 11:58, Gleb Peregud wrote:
> You can use binary comprehension:
>
> 4>  X =<<18,255,39,255,73,255,90,255,80,255>>.
> <<18,255,39,255,73,255,90,255,80,255>>
> 5>  [ H ||<<H:2/little-signed-integer-unit:8>>  <= X ].
> [-238,-217,-183,-166,-176]
>    

-- 
============================================================
Ivan A. Uemlianin
Speech Technology Research and Development

                     ivan@REDACTED
                      www.llaisdy.com
                          llaisdy.wordpress.com
                      www.linkedin.com/in/ivanuemlianin

     "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen"
                      (Schiller, Beethoven)
============================================================



More information about the erlang-questions mailing list