Skip to content

Instantly share code, notes, and snippets.

@arcusfelis
Created August 24, 2012 15:25
Show Gist options
  • Select an option

  • Save arcusfelis/3451972 to your computer and use it in GitHub Desktop.

Select an option

Save arcusfelis/3451972 to your computer and use it in GitHub Desktop.
bjoins
join([B|Bs], Sep) when is_binary(Sep) ->
R = << <<Sep/binary, X/binary>> || X <- Bs >>,
<<B/binary, R/binary>>;
join([], _Sep) ->
<<>>.
join2([B|Bs], Sep) when is_binary(Sep) ->
R = [ [Sep, X] || X <- Bs ],
iolist_to_binary([B, R]);
join2([], _Sep) ->
<<>>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment