Hi <br><br>As reading just now Chap. 5 in "Programming Erlang",<br>I can't ressist the chalange. Although not very staright forward...<br><br>reverse_binary(B) -><br> list_to_binary(lists:reverse([reverse_byte(X) || X <- binary_to_list(B)])).
<br><br>reverse_byte(B) -><br> <<B0:1, B1:1, B2:1, B3:1, B4:1, B5:1, B6:1, B7:1>> = <<B>>,<br> <<B7:1, B6:1, B5:1, B4:1, B3:1, B2:1, B1:1, B0:1>>.<br><br><br>Shimon.<br><br><div>
<span class="gmail_quote">On 8/22/07, <b class="gmail_sendername">Eranga Udesh</b> <<a href="mailto:casper2000a@omnibis.com">casper2000a@omnibis.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>Is there a straight forward and efficient method to reverse the bits in a<br>whole binary? For eg.<br><br><<bit 1 .... bit n>><br>After reversing,<br><<bit n .... bit 1>><br><br>Thanks,<br>
- Eranga<br><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">
http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br>