1
0
forked from redo/BlockLua

support more+empty args in hooks

This commit is contained in:
Redo
2025-10-13 12:28:16 -05:00
parent 7232ede09d
commit b71bfdb73e
4 changed files with 77 additions and 36 deletions

View File

@@ -13,8 +13,18 @@ function table.map(f, ...)
local u = {}
for k,_ in pairs(ts[1]) do
local args = {}
for j=1,#ts do args[j] = ts[j][i] end
u[i] = f(unpack(args))
for j=1,#ts do args[j] = ts[j][k] end
u[k] = f(unpack(args))
end
return u
end
function table.mapk(f, ...)
local ts = {...}
local u = {}
for k,_ in pairs(ts[1]) do
local args = {}
for j=1,#ts do args[j] = ts[j][k] end
u[k] = f(k, unpack(args))
end
return u
end
@@ -28,6 +38,16 @@ function table.map_list(f, ...)
end
return u
end
function table.mapi_list(f, ...)
local ts = {...}
local u = {}
for i=1,#ts[1] do
local args = {}
for j=1,#ts do args[j] = ts[j][i] end
u[i] = f(i, unpack(args))
end
return u
end
-- Swap keys/values
function table.swap(t)
local u = {}