lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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