[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.clear
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 26 Sep 2018 20:24:53 +0200
Op Wo., 26 Sep. 2018 om 20:19 het Egor Skriptunoff
<egor.skriptunoff@gmail.com> geskryf:
>
> On Wed, Sep 26, 2018 at 3:20 PM, Dirk Laurie wrote:
>>
>>
>> table.clear = function(tbl)
>> local n=#tbl
>> table.move(tbl,n+1,2*n,1)
>> end
>>
>
> Negative indices don't have "backwards" meaning in table.move(), so we can write more compact code
>
> table.clear = function(tbl)
> table.move(tbl, -#tbl, -1, 1)
> end
I considered that possibility, but an array can have non-nils at
negative integer indices without violating the sequence property.