Skip to content

Instantly share code, notes, and snippets.

@greggy
Last active February 22, 2018 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greggy/ba1e6011adbec1934db9f876fc46fa42 to your computer and use it in GitHub Desktop.
Save greggy/ba1e6011adbec1934db9f876fc46fa42 to your computer and use it in GitHub Desktop.
The example shows how to concatinate (join) the list of binaries with separator in Erlang
-module(join_binries).
-export([join/2]).
join(TitleList, Sep) ->
Fun = fun(<<>>, Acc) ->
Acc;
(Word, Acc) ->
<<Acc/binary, Sep, Word/binary>>
end,
lists:foldl(Fun, hd(TitleList), tl(TitleList)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment