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
age = 17 | |
if age > 18 then | |
print("Z") | |
elseif age >= 17 then | |
print("D") | |
elseif age >= 15 then | |
print("C") | |
elseif age >= 12 then | |
print("B") |
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
x = 10 + 5 | |
y = 5 * 5 | |
z = 10 % 3 | |
n = 2 ^ 3 | |
print(x) | |
print(y) | |
print(z) | |
print(n) |
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
n = {123, 789, "xyz"} | |
print(n[3]) | |
print(#n) | |
me = {name = "hoge", age = 17} | |
print(me["name"]) | |
print(me.age) |
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
x, y, z = 0, 0, 0 | |
-- while | |
while x <=10 do | |
x = x + 1 | |
print(x) | |
end | |
-- break | |
while y <= 10 do |
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
a = {10, 15, 20, 30} | |
b = {"ok", "ng"} | |
if a[3] > 17 then | |
print(b[1]) | |
else | |
print(b[2]) | |
end |
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
-- for | |
for i = 0, 9 do | |
print(i) | |
end | |
-- for table | |
a = {10, 20, "hoge"} | |
b = {name = "huga", age = 17} | |
for i, value in ipairs(a) do |
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
name = {"kaworun", "yozora"} | |
text1 = "さんの得点は…" | |
text2 = "さんの平均点は…" | |
ja = {49, 57} | |
en = {60, 45} | |
ss = {63, 90} | |
db = {95, 99} | |
sum = ja[1] + en[1] + ss[1] + db[1] |
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
x = math.max(200, 173, 37) | |
print(x) | |
x = math.min(2, 83, 927) | |
print(x) | |
x = math.ceil(273.7) | |
print(x) | |
x = math.floor(21.3) |
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
-- s = string.len("渚カヲル") | |
s = #("渚カヲル") | |
print(s) | |
s = string.sub("渚カヲル", 2, 3) | |
print(s) | |
s = string.find("渚カヲル", "渚") | |
print(s) |
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
x = 100 | |
y = 12.3456789 | |
name = "hogehoge" | |
s = string.format("x: %-10d, y: %.4f, name: %s", x, y, name) | |
print(s) | |
--[[ | |
left %-10~ | |
right %10~ |
OlderNewer