lua-users home
lua-l archive

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


>From lua-l@tecgraf.puc-rio.br Thu Aug 19 21:53:29 1999
>From: Steve Dekorte <steve@dekorte.com>

>Lua:
>
>  add_ = function (self, num)
>    local index, item = next(self.list(), nil)
>    while index
>      item.add_(num)
>      index, item = next(self.list(), nil)
>    end
>  end
>
>
>Lua with for:
>
>  add_ = function (self, num)
>    for item in self.list():
>      item.add_(num)
>    end
>  end

Something very close to this can be done already:

  add_ = function (self, num)
    foreach(self.list(),function (item) item.add_(%num) end)
  end

--lhf