Differences From
Artifact [eefda5e589]:
86 86 local new = fn.copy(r1)
87 87 for i=1,#r2 do
88 88 new[#new + 1] = r2[i]
89 89 end
90 90 return new
91 91 end
92 92
93 -fn.capitalize = function(str)
94 - return string.upper(string.sub(str, 1,1)) .. string.sub(str, 2)
95 -end
96 -
97 93 fn.has = function(tbl,value,eqfn)
98 94 for k,v in pairs(tbl) do
99 95 if eqfn then
100 96 if eqfn(v,value,tbl) then return true, k end
101 97 else
102 98 if value == v then return true, k end
103 99 end
................................................................................
142 138 table.sort(keys)
143 139 return fn.each(keys, function(k,i)
144 140 return f(tbl[k],k,i)
145 141 end)
146 142 end
147 143
148 144 fn.iter = function(tbl,fn)
149 - for i=1,#tbl do
150 - fn(tbl[i], i)
151 - end
145 + for i,v in ipairs(tbl) do fn(v, i) end
152 146 end
153 147
154 148 fn.map = function(tbl,fn)
155 149 local new = {}
156 150 for k,v in pairs(tbl) do
157 151 local nv, nk = fn(v, k)
158 152 new[nk or k] = nv
................................................................................
162 156
163 157 fn.fold = function(tbl,fn,acc)
164 158 if #tbl == 0 then
165 159 fn.each_o(tbl, function(v)
166 160 acc = fn(acc, v, k)
167 161 end)
168 162 else
169 - for i=0,#tbl do
170 - acc = fn(acc,tbl[i],i)
163 + for i,v in ipairs(tbl) do
164 + acc = fn(acc,v,i)
171 165 end
172 166 end
173 167 return acc
174 168 end
175 169
176 170 fn.walk = function(tbl,path)
177 171 if type(path) == 'table' then