[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Iterate over vararg
- From: Dirk Laurie <dirk.laurie@...>
- Date: Thu, 20 Dec 2018 11:37:04 +0200
Op Do. 20 Des. 2018 om 10:08 het Gabriel Bertilson
> I guess without a table, the arguments can be stored as upvalues. The
> following makes an iterator generator that sets its arguments as
> upvalues to a closure, with the total number of upvalues as the first
> upvalue. (Is there a way to avoid that first upvalue?) Then the
> closure receives an unused first argument and a second argument i, and
> it returns the i-plus-one-th argument to the original function
> (similar to the behavior of the function returned by ipairs). Not sure
> if this is more or less efficient memory-wise than using a table.
Thanks, I learnt something from your elegant code.