[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Proposal for table length operator
- From: Dirk Laurie <dpl@...>
- Date: Tue, 14 Dec 2010 10:39:38 +0200
On Tue, Dec 14, 2010 at 06:03:00AM +0200, Keith Matthews wrote:
> Given a table t, #t would be defined by those two rules:
>
> 1 - #t is the highest positive integer index to which a value was
> assigned in t (including nil)
>
> 2 - table.remove(t, i) decrements #t by 1 if i <= #t.
>
I'd prefer just Rule 1. That's the ideal way to implement sparse vectors.
-- sparse vector of length 1000
a={}; a[3]=3; a[6]=7; a[101]=101; a[1000]=nil
But now table.remove(a,3) makes #a=999? What sort of logic is that?
Dirk