1
0
Fork 0

Fix binary_join

This commit is contained in:
Daniel Kempkens 2014-07-14 21:32:28 +02:00
parent 482aba3a03
commit 01e0266dba

View file

@ -23,9 +23,8 @@ binary_join([], _Sep) ->
<<>>;
binary_join([Part], _Sep) ->
Part;
binary_join(List, Sep) ->
InitAcc = hd(List),
lists:foldr(fun (Value, Acc) -> <<Acc/binary, Sep/binary, Value/binary>> end, InitAcc, tl(List)).
binary_join([Head|Tail], Sep) ->
lists:foldl(fun (Value, Acc) -> <<Acc/binary, Sep/binary, Value/binary>> end, Head, Tail).
{% endhighlight %}
It works just like you would expect: