lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Fri, Jan 1, 2010 at 3:22 PM, Leo Razoumov <> wrote:
> It is not for the purpose of preserving the length of the result but
> rather to preserve the iteration order.

Yes, if you're thinking of doing a loop afterwards, it makes sense.
But leaving out the nils still leaves you with an array in the correct
order.  We agree that it's a bad idea for standard functions to
generate tables-with-holes; you want to replace the nils with
something that works like a boolean, and I want to simply leave them

It is true that this would only work properly with imap (the version
that uses ipairs;  there was a suggestion to make it explicit like so

The map(fun,pairs(t)) version operating on a hash-like table can be
free to leave out values

lhf asked a few or so ago why I thought simple functions like map and
filter posed interesting challenges in Lua.

This is part of the (incomplete) answer to that question ;)

steve d.