[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Map and filter without intermediate tables
- From: Geoff Leyland <geoff_leyland@...>
- Date: Fri, 8 Jun 2012 08:06:55 +1200
On 7/06/2012, at 11:30 PM, steve donovan wrote:
> On Thu, Jun 7, 2012 at 1:06 PM, Geoff Leyland <geoff_leyland@fastmail.fm> wrote:
>> Yes, but if you have a function generating a sequence and a series of sequence processors that might do things like map or filter that sequence, then you might consider avoiding intermediate tables, since there was never a table in the first place.
>
> That was the idea behind pl.seq
>
> https://github.com/stevedonovan/Penlight/blob/master/lua/pl/seq.lua
D'oh. I should have RTFM. Your implementation is similar to what Joao suggested, so I imagine it performs similarly. Do you have any feeling as to when or whether using a sequence offers (performance) advantages over a list?
Like Joao's implementation, you can't call 5.2's pairs on the result of seq.map or seq.filter, so you can't pass it to methods expecting to iterate over a table. I'm not sure how desirable that is anyway.