File: ex3.lua

package info (click to toggle)
luasocket 3.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,264 kB
  • sloc: ansic: 4,845; makefile: 337; sh: 116
file content (15 lines) | stat: -rw-r--r-- 321 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
local function chainpair(f1, f2)
  return function(chunk)
    local ret = f2(f1(chunk))
    if chunk then return ret
    else return (ret or "") .. (f2() or "") end
  end
end

function filter.chain(...)
  local f = select(1, ...)
  for i = 2, select('#', ...) do
    f = chainpair(f, select(i, ...))
  end
  return f
end