[erlang-questions] Reverses Order of Bytes in Binary

Сергей Прохоров <>
Sat Jan 10 12:24:54 CET 2015


Probably this one will be more effective

reverse(Bin) ->
    reverse(Bin, byte_size(Bin)).

reverse(_, 0) -> <<>>;
reverse(Bin, Pos) ->
    <<(binary:at(Bin, Pos - 1)), (reverse(Bin, Pos - 1))/binary >>.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150110/fa820861/attachment.html>


More information about the erlang-questions mailing list