[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: feedback on chunk
- From: Doug Currie <doug.currie@...>
- Date: Tue, 19 Apr 2011 15:10:31 -0400
On Apr 19, 2011, at 11:58 AM, David Rio Deiros wrote:
> I was wondering if I could get some feedback on the following chunk of
> lua code.
How big is pl?
Can you
(a) replace 'N' with '.' in the strings in pl
(b) turn your loop inside out and use gmatch [1] over read
?
Something like:
local function slide_over_read(read, pl)
for patt, tbl in pairs(pl) do
for w in read.gmatch(patt) do
-- do something with the matched substring w and table tbl
end
end
end
[1] http://www.lua.org/manual/5.1/manual.html#pdf-string.gmatch
e