[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Penlight and memoized list comprehensions
- From: Joshua Jensen <jjensen@...>
- Date: Tue, 01 Dec 2009 16:35:04 -0700
In comprehension.lua, there is a section that reads:
-- Convenience syntax.
-- Allows comprehension 'x^2 for x' instead of comprehension['x^2 for
x'].
mt.__call = mt.__index
Unfortunately, when using the calling syntax, it will always recreate
the generated list comprehension function.
This fix seems to make it do the right thing:
-- mt.__call = mt.__index
function mt:__call(expr)
return self[expr]
end
Can anyone (David?) comment on this?
Thanks.
Josh