[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: iterator sequences (was: Standard libraries)
- From: Wim Couwenberg <wim.couwenberg@...>
- Date: Fri, 1 Jan 2010 18:15:47 +0100
> But your map functions do have to follow the (i,val) convention
True. Passing everything that the iterator produces seemed the cleanest way.
> Although an adapter can be written for single-valued functions:
Other options are a "valseq" function to produce values or... use a filter:
function value(seq, f)
local saved_key
local function self(k, ...)
saved_key = k
return ...
end
return function(s, k)
return self(f(s, saved_key or k))
end
end
t = {
aap = "noot",
mies = "vuur",
wim = "jet",
}
for x in seq(pairs(t)) (value) do
print(x)
end
Bye,
Wim