<div dir="auto"><div dir="auto"><div dir="ltr">Why not read it with<br></div><div dir="ltr"><pre style="white-space:pre-wrap;color:rgb(8,8,8);font-size:12.8px;font-family:"jetbrains mono",monospace">ok, <span style="color:rgb(102,14,122)">Data</span>} = file:read_file(<span style="color:rgb(6,125,23)">"binary.input"</span>),</pre><pre style="white-space:pre-wrap;color:rgb(8,8,8);font-size:12.8px;font-family:"jetbrains mono",monospace">then split the binary to a list of lines</pre><pre style="white-space:pre-wrap;color:rgb(8,8,8);font-size:12.8px;font-family:"jetbrains mono",monospace">BinList = binary:split(Data,<<"\n">>,[global])</pre><pre style="white-space:pre-wrap;color:rgb(8,8,8);font-size:12.8px;font-family:"jetbrains mono",monospace">each element in the list is a binary like this:</pre><pre style="white-space:pre-wrap;color:rgb(8,8,8);font-size:12.8px;font-family:"jetbrains mono",monospace"> B = <<"1010101100">></pre><pre style="white-space:pre-wrap;color:rgb(8,8,8);font-size:12.8px;font-family:"jetbrains mono",monospace">covert this to an integer with:</pre><pre style="white-space:pre-wrap;color:rgb(8,8,8);font-size:12.8px;font-family:"jetbrains mono",monospace"><br></pre><pre style="white-space:pre-wrap;color:rgb(8,8,8);font-size:12.8px;font-family:"jetbrains mono",monospace">binary_to_integer(B,2)</pre><pre style="white-space:pre-wrap;color:rgb(8,8,8);font-size:12.8px;font-family:"jetbrains mono",monospace">and there you have your integer which you can do whatever you like with</pre><pre style="white-space:pre-wrap;color:rgb(8,8,8);font-size:12.8px;font-family:"jetbrains mono",monospace"><br></pre><pre style="white-space:pre-wrap;color:rgb(8,8,8);font-size:12.8px;font-family:"jetbrains mono",monospace">Note, this is written on my phone so it is not tested, could be some fauly detail</pre><pre style="white-space:pre-wrap;color:rgb(8,8,8);font-size:12.8px;font-family:"jetbrains mono",monospace"><br></pre><pre style="white-space:pre-wrap;color:rgb(8,8,8);font-size:12.8px;font-family:"jetbrains mono",monospace">/Kenneth </pre></div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 9, 2021 at 6:52 PM Java House <<a href="mailto:java4dev@gmail.com" rel="noreferrer noreferrer" target="_blank">java4dev@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Roger thank you for replying.<div>I am having a series of 0s an1s in a List and want to convert it to a decimal number.</div><div>I am looking for something similar to BItSet in java</div><div><br></div><div>Kind Regards</div><div>Nikolas</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Στις Πέμ 9 Δεκ 2021 στις 3:24 μ.μ., ο/η Roger Lipscombe <<a href="mailto:roger@differentpla.net" rel="noreferrer noreferrer" target="_blank">roger@differentpla.net</a>> έγραψε:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, 9 Dec 2021 at 13:29, Java House <<a href="mailto:java4dev@gmail.com" rel="noreferrer noreferrer" target="_blank">java4dev@gmail.com</a>> wrote:<br>
> Thank you Roger for the answer<br>
> I thought about it but since I have to parse all digits for every row that would mean a lot of entries as I have to create all possible combinations of 0/1 for every position of the row.<br>
<br>
parse(Data) -> parse(Data, [], []).<br>
<br>
parse(<<"0", Rest/binary>>, Line, Lines) -><br>
    parse(Rest, [false | Line], Lines);<br>
parse(<<"1", Rest/binary>>, Line, Lines) -><br>
    parse(Rest, [true | Line], Lines);<br>
parse(<<$\n, Rest/binary>>, Line, Lines) -><br>
    parse(Rest, [], [lists:reverse(Line) | Lines]);<br>
parse(<<>>, [], Lines) -> lists:reverse(Lines);<br>
parse(<<>>, Line, Lines) -> lists:reverse([lists:reverse(Line) | Lines]).<br>
<br>
...results in...<br>
<br>
[[true,true,true,false,true,true,false,false,true,false,true,false],<br>
 [false,true,false,false,true,true,true,false,true,true,true,false],<br>
 [true,true,false,false,false,true,false,false,true,false,true,false],<br>
 [false,false,true,true,false,true,false,true,true,true,false,true],<br>
 [true,true,false,true,false,false,false,false,false,false,true,true],<br>
 [false,true,false,true,true,false,true,true,false,false,true,false]]<br>
</blockquote></div>
</blockquote></div></div>