lua-users home
lua-l archive

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


On 22 Dec 2012, at 17:43, Duncan Cross wrote:

> Another way to do it is with coroutines:

I always had the impression that coroutines were quite expensive, but after a bit of searching, that doesn't seem to be the case.

I think I prefer the coroutine solution for now as it is seems simpler to understand.

I added a "return nil" at the end of the loop as iterators are supposed to return nil to signify no more elements. I know Lua adds extra nils to pad out return values, but the code makes more sense to me when it's there.

Thanks,
Kevin