[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Filtering Iterator
- From: Kevin Martin <kev82@...>
- Date: Sat, 22 Dec 2012 18:04:18 +0000
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