refactoring
This commit is contained in:
+8
-8
@@ -157,10 +157,10 @@ function public.eq(t1, t2)
|
||||
return true
|
||||
end
|
||||
|
||||
function public.any(t, p)
|
||||
function public.any(t, predicate)
|
||||
for _, v in t do
|
||||
if p then
|
||||
if p(v) then return true end
|
||||
if predicate then
|
||||
if predicate(v) then return true end
|
||||
elseif v then
|
||||
return true
|
||||
end
|
||||
@@ -168,10 +168,10 @@ function public.any(t, p)
|
||||
return false
|
||||
end
|
||||
|
||||
function public.all(t, p)
|
||||
function public.all(t, predicate)
|
||||
for _, v in t do
|
||||
if p then
|
||||
if not p(v) then return false end
|
||||
if predicate then
|
||||
if not predicate(v) then return false end
|
||||
elseif not v then
|
||||
return false
|
||||
end
|
||||
@@ -179,9 +179,9 @@ function public.all(t, p)
|
||||
return true
|
||||
end
|
||||
|
||||
function public.filter(t, p)
|
||||
function public.filter(t, predicate)
|
||||
for k, v in t do
|
||||
if not p(v, k) then t[k] = nil end
|
||||
if not predicate(v, k) then t[k] = nil end
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
+1
-1
@@ -6,8 +6,8 @@ SILVER_TEXT = '|cffc7c7cfs|r'
|
||||
COPPER_TEXT = '|cffeda55fc|r'
|
||||
private()
|
||||
|
||||
COPPER_PER_SILVER = 100
|
||||
COPPER_PER_GOLD = 10000
|
||||
COPPER_PER_SILVER = 100
|
||||
|
||||
function public.to_gsc(money)
|
||||
local gold = floor(money / COPPER_PER_GOLD)
|
||||
|
||||
Reference in New Issue
Block a user