lua-users home
lua-l archive

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


Dirk Laurie <dirk.laurie@gmail.com> writes:
>> Given the prevalence of "iterate over the values only" in many
>> languages, it is a bit odd that Lua doesn't have it.
>
> As always, Lua provides the soup and the spoon, but you have
> to do your own feeding.
>
> ivalues = function(tbl);
>    local k=0
>    return function() k=k+1; return tbl[k] end
> end

Sure, but in practice, one probably doesn't want to pay the price of a
closure just for that...

-miles

-- 
"Suppose we've chosen the wrong god. Every time we go to church we're
just making him madder and madder." -- Homer Simpson