20 lines
365 B
Lua
20 lines
365 B
Lua
function split(text, sep)
|
|
local parts = {}
|
|
local start = 0
|
|
local from, to = text:find(sep)
|
|
while from ~= nil do
|
|
table.insert(parts, text:sub(start, from - 1))
|
|
text = text:sub(to + 1)
|
|
from, to = text:find(sep)
|
|
end
|
|
table.insert(parts, text)
|
|
return parts
|
|
end
|
|
|
|
function sign(n)
|
|
if n == 0 then return 0
|
|
elseif n < 0 then return -1
|
|
else return 1
|
|
end
|
|
end
|