Well, GSM using weird coding.<br>This similar to your solution is:<br><br>unpack(UD) -><br>    << <<0:1,A:1,B:1,C:1,D:1,E:1,F:1,G:1>> ||<br>        <<G:1,F:1,E:1,D:1,C:1,B:1,A:1>> <=<br>
            << <<A:1,B:1,C:1,D:1,E:1,F:1,G:1,H:1>> || <<H:1,G:1,F:1,E:1,D:1,C:1,B:1,A:1>> <= UD >><br>    >>.<br><br>It is 2-10 times faster on my laptop (depend of GC hit) in byte code and 4 times in native.<br>
<br><div class="gmail_quote">2009/3/5 Tony Seebregts <span dir="ltr"><<a href="mailto:tony.seebregts@gmail.com">tony.seebregts@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><span style="border-collapse: collapse;">Hmmm , the short answer is that the code I suggested is taken from a module to convert a GSM octet stream into a septet stream and it gives a different answer when using your more compact code :-) :<div>

<br></div><div><div>UD:      << 203,176,184,204,86,191,1 >></div><div>Mine:    [75,97,98,101,108,106,111,0]<br></div><div>Yours:  << 101,108,23,12,98,90,126,1>><br></div><div><br></div><div>I remember the GSM octet-septet conversion being quite awkward to get right because the bytes were the 'wrong way round'  which is probably why I ended up with the code I did i.e. having to use flip(...).</div>

<div><br></div></div></span><br></div><div class="gmail_quote"><div class="im">2009/3/5 Hynek Vychodil <span dir="ltr"><<a href="mailto:vychodil.hynek@gmail.com" target="_blank">vychodil.hynek@gmail.com</a>></span><br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Why not?<div><div></div><div class="h5"><br><br>unpack(UD) -><br>  << <<0:1,X/bits>> || <<X:7/bits>> <= UD >>.<br><br><div class="gmail_quote">2009/3/5 Tony Seebregts <span dir="ltr"><<a href="mailto:tony.seebregts@gmail.com" target="_blank">tony.seebregts@gmail.com</a>></span><br>


<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div>This is an extract from the code I use:<div><br></div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">



<div>unpack(UD) -></div><div>   septets(list_to_binary([ flip(X) || X <- binary_to_list(UD) ])).</div><div><br></div><div>septets(T) -></div><div>    [ flipx(X) || <<X:7>> <= T].</div><div><br></div>



<div>% Flips the bits in an octet/septet for easy unpacking</div><div><br></div><div>flip(Octet) -></div><div>   <<B8:1,B7:1,B6:1,B5:1,B4:1,B3:1,B2:1,B1:1>>  = <<Octet>>,</div><div>   <<B1:1,B2:1,B3:1,B4:1,B5:1,B6:1,B7:1,B8:1>>.</div>



</blockquote><div> </div><div>There is probably a better way of doing it but I was in a rush at the time :-)</div><div><br></div><div><br></div><div><br></div><div><br></div></div>
<br></div></div>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><font color="#888888"><br><br clear="all"><br>-- <br>--Hynek (Pichi) Vychodil<br>


<br>Analyze your data in minutes. Share your insights instantly. Thrill your boss.  Be a data hero!<br>Try Good Data now for free: <a href="http://www.gooddata.com" target="_blank">www.gooddata.com</a><br>
</font></div></div></blockquote></div><br>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br><br clear="all"><br>-- <br>--Hynek (Pichi) Vychodil<br>
<br>Analyze your data in minutes. Share your insights instantly. Thrill your boss.  Be a data hero!<br>Try Good Data now for free: <a href="http://www.gooddata.com">www.gooddata.com</a><br>