You are writing a comment about Writing Join in Erlang, here is a quick summary:
Erlang doesn't have a built in function for joining strings, and so I sat down to put one together quickly. A quick look at two different ways that join can be implemented.
You are responding to this comment written by Per Melin on May 5th 2008, 18:32.
But that was slower than the stdlib string implementation.
I wrote this, thinking it would be faster than the stdlib version:
join2([H|T], Sep) ->
lists:concat([H|[P || X <- T, P <- [Sep, X]]]).
It wasn't. But this is:
join3([], _Sep) -> [];
join3([T], _Sep) -> T;
join3([H|T], Sep) -> H ++ Sep ++ join3(T, Sep).
It's about 20% faster on my machine, and 50% faster with hipe. Of course it's not tail recursive, so performance may suffer for extremely long lists.
Please be aware that comment forms go stale after one hour.
Comments may make use of LifeFlow MarkDown. Raw html will be escaped.
Quick Introduction to LifeFlow MarkDown Syntax
A highlighted code block:
Other common languages work as well: scheme, python, java, html, etc.
Other markdown syntax: