Fix binary_join
This commit is contained in:
parent
482aba3a03
commit
01e0266dba
1 changed files with 2 additions and 3 deletions
|
@ -23,9 +23,8 @@ binary_join([], _Sep) ->
|
||||||
<<>>;
|
<<>>;
|
||||||
binary_join([Part], _Sep) ->
|
binary_join([Part], _Sep) ->
|
||||||
Part;
|
Part;
|
||||||
binary_join(List, Sep) ->
|
binary_join([Head|Tail], Sep) ->
|
||||||
InitAcc = hd(List),
|
lists:foldl(fun (Value, Acc) -> <<Acc/binary, Sep/binary, Value/binary>> end, Head, Tail).
|
||||||
lists:foldr(fun (Value, Acc) -> <<Acc/binary, Sep/binary, Value/binary>> end, InitAcc, tl(List)).
|
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
It works just like you would expect:
|
It works just like you would expect:
|
||||||
|
|
Loading…
Reference in a new issue