Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
%% Join binary values using the specified separator.
binary_join([], _) -> <<"">>;
binary_join([H|[]], _) -> H;
binary_join(L, Sep) when is_list(Sep) ->
binary_join(L, list_to_binary(Sep));
binary_join([H|T], Sep) ->
binary_join(T, H, Sep).
binary_join([], Acc, _) ->
binary_join([H|T], Acc, Sep) ->
binary_join(T, <<Acc/binary, Sep/binary, H/binary>>, Sep).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment