-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathParserUtils.lua
More file actions
46 lines (37 loc) · 781 Bytes
/
Copy pathParserUtils.lua
File metadata and controls
46 lines (37 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function reverseMap(map)
local newMap = {}
for k, v in pairs(map) do
newMap[v] = k
end
return newMap
end
function filterByValueType(map, fType)
local newMap = {}
fType = fType or "number"
for k, v in pairs(map) do
if (type(v) == fType) then
newMap[k] = v
end
end
return newMap
end
function pairsByKeys (t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then return nil
else return a[i], t[a[i]]
end
end
return iter
end
function tableKeyMapDeconstruct(map, i)
local newMap = {}
for j, x in pairs(map) do
newMap[j[i]] = x
end
return newMap
end