Last active
April 21, 2020 12:18
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- running luajit in repl will be useful for exploration | |
-- docker run -it --rm akorn/luajit:2.1-alpine | |
-- just inspired at | |
-- https://stackoverflow.com/questions/1426954/split-string-in-lua | |
function mysplit (inputstr, sep) | |
if sep == nil then | |
sep = "%s" | |
end | |
local t={} | |
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do | |
table.insert(t, str) | |
end | |
return t | |
end | |
codeparts = mysplit("luaphase||luacode", "||") | |
print(codeparts[1]) | |
-- luaphase | |
print(codeparts[2]) | |
-- luacode | |
luacode = "a = 0 \n a = a + 1 \n print(a) \n" | |
luacodefunction = loadstring(luacode) | |
luacodefunction() | |
-- 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment