--- lam.util local m = {} function m.pop (tbl) --[[ Remove the first element from TBL. ]] return table.remove(tbl, 1) end function m.proc (arity, fn) --[[ Wrap RN in a check that for its ARITY. ARITY can be a number, the minimum number of arguments, or a table {MIN, MAX}. If MIN is nil or absent, it's 0; if MAX is nil or absent, it's infinity. MIN and MAX are both inclusive. ]] local rmin, rmax, rstr if type(arity) ~= "table" then rmin, rmax = arity, arity rstr = rmin else rmin, rmax = arity[1] or 0, arity[2] or 1/0 -- infinity rstr = rmin .. ".." .. rmax end return function (r) local rlen = r and #r or 0 if rlen < rmin or rlen > rmax then error(string.format("Wrong arity: %s, need %s", rlen, rstr)) end return fn(r) end end --- return m