Skip to content

Instantly share code, notes, and snippets.

@alexeyr
Created October 2, 2010 07:33
Show Gist options
  • Select an option

  • Save alexeyr/607419 to your computer and use it in GitHub Desktop.

Select an option

Save alexeyr/607419 to your computer and use it in GitHub Desktop.
-define(APPEND_IF_BIT_SET(BitMap, Bit, Binary, Continuation),
case byteset:contains(BitMap, Bit) of
true -> <<Binary/binary, Continuation>>;
false -> Binary
end).
-define(PREPEND_IF_BIT_SET(BitMap, Bit,
PatternInBinary, PatternInList,
OldRestVar, NewRestVar,
OldAccVar, NewAccVar),
case byteset:contains(BitMap, Bit) of
true ->
<<PatternInBinary, NewRestVar/binary>> = OldRestVar,
NewAccVar = [PatternInList | OldAccVar];
false ->
NewRestVar = OldRestVar,
NewAccVar = OldAccVar
end).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment