lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi, all!

ISuppose I have a table of functions. Each of functions returns the
string (different one). I need to concatenate all results into one
large string.

I've read somewhere, that table.concat() is faster that series of
separate concatenations. So, is following approach faster than
concatenation in a loop?

foo = function(funcs)
 local t = { }
 for _, fun in pairs(funcs) do
   table.insert(t, fun())
 end
 return table.concat(t)
end

Or is there more elegant way to do what I want (still, in this case
I'd prefer elegancy over speed ;) )?

Thanks in advance,
Alexander.