ex3.lua 322 B

123456789101112131415
  1. local function chainpair(f1, f2)
  2. return function(chunk)
  3. local ret = f2(f1(chunk))
  4. if chunk then return ret
  5. else return (ret or "") .. (f2() or "") end
  6. end
  7. end
  8. function filter.chain(...)
  9. local f = select(1, ...)
  10. for i = 2, select('#', ...) do
  11. f = chainpair(f, select(i, ...))
  12. end
  13. return f
  14. end