51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
new[k] = fn.deepcopy(v)
else
new[k] = v
end
end
return new
end
fn.merge = function(base,override)
local new = fn.copy(base)
for k,v in pairs(override) do
new[k] = v
end
return new
end
fn.deepmerge = function(base,override,func)
local new = {}
local keys = fn.merge(fn.keys(base),fn.keys(override))
for _,k in pairs(keys) do
if type(base[k]) == 'table' and
type(override[k]) == 'table' then
new[k] = fn.deepmerge(base[k], override[k], func)
elseif func and override[k] and base[k] then
new[k] = func(base[k],override[k], k)
elseif override[k] then
new[k] = override[k]
else
new[k] = base[k]
end
end
return new
end
fn.append = function(r1, r2)
local new = fn.copy(r1)
for i=1,#r2 do
new[#new + 1] = r2[i]
end
return new
end
fn.has = function(tbl,value,eqfn)
for k,v in pairs(tbl) do
if eqfn then
if eqfn(v,value,tbl) then return true, k end
|
>
>
>
>
>
>
>
>
|
<
<
<
<
<
<
<
<
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
new[k] = fn.deepcopy(v)
else
new[k] = v
end
end
return new
end
fn.append = function(r1, r2)
local new = fn.copy(r1)
for i=1,#r2 do
new[#new + 1] = r2[i]
end
return new
end
fn.merge = function(base,override)
local new = fn.copy(base)
for k,v in pairs(override) do
new[k] = v
end
return new
end
fn.deepmerge = function(base,override,func)
local new = {}
local keys = fn.append(fn.keys(base),fn.keys(override))
for _,k in pairs(keys) do
if type(base[k]) == 'table' and
type(override[k]) == 'table' then
new[k] = fn.deepmerge(base[k], override[k], func)
elseif func and override[k] and base[k] then
new[k] = func(base[k],override[k], k)
elseif override[k] then
new[k] = override[k]
else
new[k] = base[k]
end
end
return new
end
fn.has = function(tbl,value,eqfn)
for k,v in pairs(tbl) do
if eqfn then
if eqfn(v,value,tbl) then return true, k end
|