[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: pairs and ipairs
- From: Francisco Olarte <folarte@...>
- Date: Mon, 23 Oct 2023 19:18:23 +0200
On Mon, 23 Oct 2023 at 19:03, Petite Abeille <petite.abeille@gmail.com> wrote:
> > local aNext = 1
> > while aTable[aNext] ~= nil do
> > aNext = aNext+1
> > end
>
> ^ This is the crux of the irritant though — two passes.
I had a solution which works if all the initial sequence is iterated
before the rest, but this is not the case ( it can live partially in
the hash part, I found that in test ). It can even be trivially made
to work if the indexes of the initial sequence are guaranteed to be
iterated in order by next, but I think that is not the case. Given
this restrictions you either do nasty things ( like storing every
integer index somewhere else, spitting it out as you go ) or
precalculate the integer range to skip.
> As someone mentioned earlier on, perhaps best not to put oneself into this situation in the first place — use two tables.
Normally if I have a "record" table everything is "fields", if it has
an "array" I store it in a field, but I'm not sure of the constraints
imposed by the OP host environment.
Francisco Olarte.