lua-users home
lua-l archive

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


Jay Carlson wrote:
> I'm getting tired of typing
>
> for i=1,getn(l) do
>   local v=l[i]
>   [...]
> end
>
> It makes the loop look more complicated than it is, harder to
> understand at first glance etc.  What I'd like is something like
>
> for i,v in list l do
>   [...]
> end

A while back I made a small patch for 4.0 that takes care of this (see Power
Patches page on the Lua Wiki).  However my patch doesn't provide the index
value.  Edgar T's Sol provides exactly what you wrote but you may have a
hard time picking out the necessary changes.

-John