aboutsummaryrefslogtreecommitdiff
path: root/src/syslua/test.lua
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2017-01-26 17:43:38 +0100
committerAlex Auvolat <alex@adnab.me>2017-01-26 17:43:38 +0100
commit96da27494f89d75f8aec0c8894440c3f7482f54b (patch)
treea239f75acf6c2c11cfa54b895653f978980064cb /src/syslua/test.lua
parent809d660944cfb515e18bb7f1c1519392b4bccd53 (diff)
downloadkogata-96da27494f89d75f8aec0c8894440c3f7482f54b.tar.gz
kogata-96da27494f89d75f8aec0c8894440c3f7482f54b.zip
More lua
Diffstat (limited to 'src/syslua/test.lua')
-rw-r--r--src/syslua/test.lua25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/syslua/test.lua b/src/syslua/test.lua
index 67b2852..7c9989c 100644
--- a/src/syslua/test.lua
+++ b/src/syslua/test.lua
@@ -1,7 +1,29 @@
print("Hello, world! (printed)")
+local t = {}
-return function(n)
+function t.decomp(x)
+ local ret = {}
+ for i = 2, x do
+ while x % i == 0 do
+ table.insert(ret, i)
+ x = x // i
+ end
+ end
+ return ret
+end
+
+function t.pretty(n)
+ for i = 1, n do
+ local d = t.decomp(i)
+ for _, v in pairs(d) do
+ io.stdout:write(('-'):rep(v) .. ' ')
+ end
+ io.stdout:write('\n')
+ end
+end
+
+function t.guess(n)
local a = math.random(n)
while true do
io.stdout:write("Guess? ")
@@ -17,3 +39,4 @@ return function(n)
end
end
+return t