From 01e0266dba99daa4fc46bcd90d8850623b62a98d Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Mon, 14 Jul 2014 21:32:28 +0200 Subject: [PATCH] Fix binary_join --- _posts/2014-02-16-joining-a-list-of-binaries-in-erlang.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/_posts/2014-02-16-joining-a-list-of-binaries-in-erlang.md b/_posts/2014-02-16-joining-a-list-of-binaries-in-erlang.md index 010a96c..c48d213 100644 --- a/_posts/2014-02-16-joining-a-list-of-binaries-in-erlang.md +++ b/_posts/2014-02-16-joining-a-list-of-binaries-in-erlang.md @@ -23,9 +23,8 @@ binary_join([], _Sep) -> <<>>; binary_join([Part], _Sep) -> Part; -binary_join(List, Sep) -> - InitAcc = hd(List), - lists:foldr(fun (Value, Acc) -> <> end, InitAcc, tl(List)). +binary_join([Head|Tail], Sep) -> + lists:foldl(fun (Value, Acc) -> <> end, Head, Tail). {% endhighlight %} It works just like you would expect: