How to write a list of integers to a file as 16 bit values in Elixir -


i have list of integers values between [0-65535]. need write these file 16 bit integers.

how do in elixir?

i have searched, confused ints , binaries , how perform conversion 16 bit values.

i have found how convert 16 bit binary:

<<12345 :: size(16)>> 

you can alternatively use streams:

[1, 2, 3] |> stream.map(&<<&1::16>>) |> enum.into(file.stream!(filename)) 

this uses short form ::16 instead of ::size(16). file stream take care of opening , closing file automatically.


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -