From 77950d5aa7119faf02c1d8b74ba6f6e9d603bd91 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Mon, 12 Sep 2016 12:06:37 +0200 Subject: [PATCH] backup --- util/core.lua | 44 +++++++++++++------------------------------- util/filter.lua | 4 ++-- 2 files changed, 15 insertions(+), 33 deletions(-) diff --git a/util/core.lua b/util/core.lua index 429d382..a92bff1 100644 --- a/util/core.lua +++ b/util/core.lua @@ -73,46 +73,28 @@ do state = nil return temp end - function public.present(v) state = v; return f end + function public.present(v) + state = v + return f + end end -do - local formal_parameters = t - for i = 1, 9 do - local key = '_' .. i - public[key] = t - formal_parameters[_E[key]] = i - end - local function helper(f, arg1, arg2) - local params = t - for i = 1, arg1.n do - if formal_parameters[arg1[i]] then - tinsert(params, arg2[formal_parameters[arg1[i]]]) - else - tinsert(params, arg1[i]) - end +function public.vararg.L(arg) + local f = tremove(arg, 1) + local arg1 = perm-arg + return vararg(function(arg) + for i = 1, getn(arg) do + tinsert(arg1, arg[i]) end - return f(unpack(params)) - end - function public.L(body, ...) - if type(body) == 'function' then - local arg1 = arg - return function(...) return helper(body, arg1, arg) end - else -- TODO memoization --- body = gsub(body, '_([ab])', function(char) return '_' .. end) --- local lambda = loadstring('return function(_1,_2,_3,_4,_5,_6,_7,_8,_9)' .. body .. ' end') - local lambda = loadstring('return ' .. body) or loadstring(body) or error() - setfenv(lambda, getfenv(2)) - return lambda - end - end + return f(unpack(arg1)) + end) end function public.index(t, ...) auto[arg] = true for i = 1, arg.n do t = t and t[arg[i]] end return t end -public.huge = 1.8*10^308 +public.huge = 1.8 * 10 ^ 308 function public.modified.get() return IsShiftKeyDown() or IsControlKeyDown() or IsAltKeyDown() end diff --git a/util/filter.lua b/util/filter.lua index 131978f..4dea9d0 100644 --- a/util/filter.lua +++ b/util/filter.lua @@ -233,8 +233,8 @@ do end for _, parser in temp-A( temp-A('class', info.item_class_index), - temp-A('subclass', L(info.item_subclass_index, index(self.class, 2) or 0, _1)), - temp-A('slot', L(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0, _1)), + temp-A('subclass', L(info.item_subclass_index, index(self.class, 2) or 0)), + temp-A('slot', L(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0)), temp-A('quality', info.item_quality_index) ) do if not self[parser[1]] then