-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctionList.lua
42 lines (39 loc) · 911 Bytes
/
functionList.lua
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
function splitString(str, pat)
local t = {}
local fpat = "(.-)" .. pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
return t
end
function dumpTable(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
-- key 가 숫자가 아닌 경우 "key"
if type(k) ~= 'number' then
k = '"'..k..'"'
end
s = s .. '['..k..'] = ' .. dumpTable(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
function contains(list, x)
for _, v in pairs(list) do
if v == x then return true end
end
return false
end