[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Possible Lua enhancements 2: Piping
- From: Mark Hamburg <mark@...>
- Date: Thu, 18 Dec 2008 17:13:42 -0800
Having said it would be easier to write in C, now I'm worrying about
how to write pipe in pure Lua...
function pipe( fn, ... )
if select( '#', ... ) == 0 then
return fn
else
local rest = pipe( ... )
return function( ... )
return rest( fn( ... ) )
end
end
end
As long as one reuses the pipe, the cost of the chain construction
probably isn't too bad.
Mark