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' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -