107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
...
251
252
253
254
255
256
257
258
259
|
fn.pick = function(lst)
local keys = fn.keys(lst)
local k = keys[math.random(#keys)]
return k, lst[k]
end
fn.unpack = table.unpack or unpack or function(tbl,i)
i = i or 1
if #tbl == i then return tbl[i] end
return tbl[i], fn.unpack(tbl, i+1)
end
fn.split = function(...) return fn.unpack(lib.str.explode(...)) end
fn.each = function(tbl,f)
local r = {}
for k,v in pairs(tbl) do
local v, c = f(v,k)
................................................................................
fn.set = function(...)
local s = {}
fn.setOrD(s, ...)
return s
end
return fn
|
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
...
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
|
fn.pick = function(lst)
local keys = fn.keys(lst)
local k = keys[math.random(#keys)]
return k, lst[k]
end
fn.unpack = table.unpack or unpack --[[or function(tbl,i)
i = i or 1
if #tbl == i then return tbl[i] end
return tbl[i], fn.unpack(tbl, i+1)
end]]
fn.split = function(...) return fn.unpack(lib.str.explode(...)) end
fn.each = function(tbl,f)
local r = {}
for k,v in pairs(tbl) do
local v, c = f(v,k)
................................................................................
fn.set = function(...)
local s = {}
fn.setOrD(s, ...)
return s
end
fn.lerp = function(t, a, b)
local r = {}
for k in next, a do
r[k] = lib.math.lerp(t, a[k], b[k])
end
return r
end
return fn
|