[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Symmetry between language and C API (Was: (not) handling new programming idioms with grace
- From: Scott Morgan <blumf@...>
- Date: Mon, 23 Jul 2018 15:10:54 +0100
On 23/07/18 15:07, Scott Morgan wrote:
> How about:
>
> function concat(list, sep, i, j)
> i = i or 1
> j = j or #list
>
> local tmp = {}
> for i=1,#list do
> tmp[i] = tostring(list[i])
> end
> return table.concat(tmp, sep, i, j)
> end
>
> Which would just be O(n)?
>
> Might be able to improve with table.pack/unpack, maybe.
And I notice the mistake in the loop, doh!
Should be `for k=i,j do` etc. etc.
Scott