Delete the first entry of an array.
Alex Tweedly
alex at tweedly.net
Sat Mar 26 19:40:50 EDT 2016
On 26/03/2016 07:35, Peter TB Brett wrote:
> On 25/03/2016 23:00, Alex Tweedly wrote:
>
>> How about a Feature Exchange for adding arrays ? (i.e. not
>> dictionaries, but actual arrays with numeric indices and linear access
>> times)
>
> In LiveCode, we currently call these "proper lists".
>
> LiveCode arrays currently have O(log N) read and insertion complexity
> in the general case (which is better than linear).
>
> If we were to add proper lists, we would probably use an
> implementation with O(1) read and O(N) insertion complexity in the
> general case.
>
Yes, sorry, I said it badly, leading to some confusion.
I meant "linear access time" for accessing every element of the array in
turn - i.e. (roughly) equivalent to "constant access time" for an
individual access.
> If you need proper lists, LiveCode Builder already provides them with
> the "List" type.
>
I haven't found (can't find) a spec for LCB, so I'm not sure exactly
what "proper lists" are - but I think maybe not quite what I meant.
I was thinking of "proper arrays" :-) i.e. real, old-fashioned indexed
arrays - see Algol, Fortran, etc.
So we would have
read access in constant time
write access in constant time
insertion complexity - there is no such thing as insertion :-)
OK, given that we would never want to require array declarations to
define bounds, there might be some extra cost on extending the bounds,
but that would be occasional, so we would in general have constant
access time (for either read or write).
And, of course, if it were done in LCB it would be even more
advantageous because we would pre-define the data type, and hence be
able to do completely dense arrays, just like Fortran etc. (he said,
making about 50 wild assumptions about a language he can't find a spec
for :-)
Regards
-- Alex.
More information about the use-livecode
mailing list