plunkerでlua その2
概要
plunkerでluaやってみた。
参考にしたページ
サンプルコード
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
<script src="https://fengari.io/static/js/fengari-web.js?v=1" type="text/javascript"></script>
</head>
<body>
<h1>Hello Plunker!</h1>
<script type="application/lua" async>
local js = require "js"
local window = js.global
function CreateRandStr(length)
local length = length or 0
if length <= 0 then
return nil
end
local random_strs = {}
if length > 0 then
math.randomseed(os.time())
for i= 1, length do
local a = math.random(97, 122)
local c = math.random(65, 90)
local i = math.random(48, 57)
local w = math.random(1, 3)
if w == 1 then table.insert(random_strs, string.char(a)) end
if w == 2 then table.insert(random_strs, string.char(c)) end
if w == 3 then table.insert(random_strs, string.char(i)) end
end
end
return table.concat(random_strs, "")
end
window:alert(CreateRandStr(10))
</script>
</body>
</html>
成果物
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
<script src="https://fengari.io/static/js/fengari-web.js?v=1" type="text/javascript"></script>
</head>
<body>
<h1>Hello Plunker!</h1>
<script type="application/lua" async>
local js = require "js"
local window = js.global
function CreateRandStr(length)
local length = length or 0
if length <= 0 then
return nil
end
local random_strs = {}
if length > 0 then
math.randomseed(os.time())
for i= 1, length do
local a = math.random(97, 122)
local c = math.random(65, 90)
local i = math.random(48, 57)
local w = math.random(1, 3)
if w == 1 then table.insert(random_strs, string.char(a)) end
if w == 2 then table.insert(random_strs, string.char(c)) end
if w == 3 then table.insert(random_strs, string.char(i)) end
end
end
return table.concat(random_strs, "")
end
window:alert(CreateRandStr(10))
</script>
</body>
</html>
以上。
Author And Source
この問題について(plunkerでlua その2), 我々は、より多くの情報をここで見つけました https://qiita.com/ohisama@github/items/5a7be47b8db32bb0ae85著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .