[erlang-questions] join/2 function
Mon Dec 18 10:39:19 CET 2006
On 12/18/06, Torbjorn Tornkvist <tobbe@REDACTED> wrote:
> My take on this was:
> t3(List, Sep) ->
> lists:foldr(fun(X,) -> X; (X,Acc) -> X++Sep++Acc end, "", List).
> See the attached file for all three versions.
I thought I'd test with really many and large lists, and the results
are pretty much like Tobbes, something like (for a list of 100 lists
of 1000 elements, repeated some 10 times)
But testing t2 without the flatten (because as Matthias pointed out,
it isn't necessary in many cases) the result is
I think the difference is notable enough to be worthy of mentioning --
don't flatten unless you need to!
More information about the erlang-questions