Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Provides some idiomatic tools to help when programming using Erlang's Binary primitive type.
break(Blocksize, Bin) ->
<<Head:Blocksize/bits, Rest/bits>> = Bin,
{Head, Rest}.
foreach(_, _, <<>>) -> ok;
foreach(F, Blocksize, Bin) ->
{Head, Rest} = break(Blocksize, Bin),
foreach(F, Blocksize, Rest).
fold(_, Result, _, <<>>) -> Result;
fold(F, Initial, Blocksize, Bin) ->
{Head, Rest} = break(Blocksize, Bin),
Temp = F(Initial, Head),
fold(F, Temp, Blocksize, Rest).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.