sorcery  Diff

Differences From Artifact [d54be79f29]:

To Artifact [990a6e8caf]:


206
207
208
209
210
211
212
213



















214
end

fn.cond = function(exp, c)
	for i, v in ipairs(c) do
		if c[1](exp) then return c[2](exp) end
	end
end




















return fn








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
end

fn.cond = function(exp, c)
	for i, v in ipairs(c) do
		if c[1](exp) then return c[2](exp) end
	end
end

fn.select = function(tbl, prop, ...)
	local keycache
	local check if type(prop) == 'function' then
		check = prop
		keycache = ...
	else
		local val val, keycache = ...
		check = function(ent) return ent[prop] == val end
	end
	for k,v in pairs(tbl) do
		if (not keycache) or (not keycache[k]) then -- help avoid expensive selectors
			if check(v,k) then
				if keycache then keycache[k] = true end
				return v, k
			end
		end
	end
end

return fn