module refactoring

This commit is contained in:
Manuel Simon Hirsig
2017-11-25 17:53:10 +01:00
parent 6f71167e48
commit ab94acc2be
38 changed files with 402 additions and 453 deletions
+6 -11
View File
@@ -4,12 +4,16 @@ local T = require 'T'
M.immutable = setmetatable(T.acquire(), {
__metatable = false,
__newindex = nop,
__newindex = pass,
__sub = function(_, t)
return setmetatable(T.acquire(), T.map('__metatable', false, '__newindex', nop, '__index', t))
return setmetatable(T.acquire(), T.map('__metatable', false, '__newindex', pass, '__index', t))
end
})
function M.enum(n)
if n > 0 then return immutable-{}, enum(n - 1) end
end
M.select = T.vararg-function(arg)
for _ = 1, arg[1] do
tremove(arg, 1)
@@ -23,15 +27,6 @@ end
M.join = table.concat
function M.range(arg1, arg2)
local i, n = arg2 and arg1 or 1, arg2 or arg1
if i <= n then return first, range(i + 1, n) end
end
function M.replicate(count, value)
if count > 0 then return value, replicate(count - 1, value) end
end
M.index = T.vararg-function(arg)
local t = tremove(arg, 1)
for _, v in ipairs(arg) do