[erlang-questions] Reverses Order of Bytes in Binary

Max Lapshin max.lapshin@REDACTED
Fri Jan 9 15:18:26 CET 2015


Ah, really.  I should be ashamed.

reverse(Bin) ->
  reverse(Bin, []).

reverse(<<>>, Acc) -> list_to_binary(Acc);
reverse(<<C,Bin/binary>>, Acc) -> reverse(Bin, [C|Acc]).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150109/1d177b40/attachment.htm>


More information about the erlang-questions mailing list