[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Definition of a sequence
- From: Mike <lua-l@...>
- Date: Thu, 11 Jun 2015 11:45:16 +0300
On Thu, 11 Jun 2015 11:29:01 +0300
Mike <...> wrote:
> On Tue, 9 Jun 2015 22:58:56 -0500
> Andrew Starks <...> wrote:
> >
> > However, tables have two features that work if you have a sequence: the
> > length operator will return the last integral index and ipairs will
> > iterate, *in order* from 1 to max n.
>
> In fact the length operator behafior is more complicated and unpredictable:
> ---------
> Lua 5.3.0 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> > =#{1, 2, nil, 4, 0}
> 5
> > =#{1, 2, nil, 4, 0, nil}
> 2
> > =#{1, 2, nil, 4, nil, 0, nil}
> 2
> > =#{1, 2, nil, 4, nil, nil, 0, nil}
> 4
> >
> ---------
>
>
For comparison:
---------
LuaJIT 2.0.4 -- Copyright (C) 2005-2015 Mike Pall. http://luajit.org/
JIT: ON CMOV SSE2 SSE3 AMD fold cse dce fwd dse narrow loop abc sink fuse
> =#{1, 2, nil, 4, 0}
5
> =#{1, 2, nil, 4, 0, nil}
5
> =#{1, 2, nil, 4, nil, 0, nil}
6
> =#{1, 2, nil, 4, nil, nil, 0, nil}
4
>
---------
--
Mike
- References:
- Definition of a sequence, Dirk Laurie
- Re: Definition of a sequence, Tim Hill
- Re: Definition of a sequence, Dirk Laurie
- Re: Definition of a sequence, Tim Hill
- Re: Definition of a sequence, Dirk Laurie
- Re: Definition of a sequence, Tim Hill
- Re: Definition of a sequence, "书呆彭, Peng Yi"
- Re: Definition of a sequence, Andrew Starks
- Re: Definition of a sequence, Mike