add utils, use luajit which seems faster
This commit is contained in:
parent
87637a4682
commit
fad5da2e27
5 changed files with 33 additions and 25 deletions
19
utils.lua
Normal file
19
utils.lua
Normal file
|
@ -0,0 +1,19 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue