summaryrefslogtreecommitdiff
path: root/lua_benchmark/tests/Lua-Benchmarks/ack.lua
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2024-05-17 15:57:30 -0700
committerMatthew Sotoudeh <matthew@masot.net>2024-05-17 15:57:30 -0700
commitd068f0b3c11348a50c18af1ee3b0d2e5f38c4faf (patch)
treedb777acca2336f8c279e9f09346f02de7ddaa0e9 /lua_benchmark/tests/Lua-Benchmarks/ack.lua
parent221b05e7a86faa38036429d5fbfc8b0779eb5382 (diff)
lua benchmarks
Diffstat (limited to 'lua_benchmark/tests/Lua-Benchmarks/ack.lua')
-rw-r--r--lua_benchmark/tests/Lua-Benchmarks/ack.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/lua_benchmark/tests/Lua-Benchmarks/ack.lua b/lua_benchmark/tests/Lua-Benchmarks/ack.lua
new file mode 100644
index 0000000..3b41935
--- /dev/null
+++ b/lua_benchmark/tests/Lua-Benchmarks/ack.lua
@@ -0,0 +1,16 @@
+-- $Id: ackermann.lua,v 1.5 2000/12/09 20:07:43 doug Exp $
+-- http://www.bagley.org/~doug/shootout/
+
+local function Ack(M, N)
+ if (M == 0) then
+ return N + 1
+ end
+ if (N == 0) then
+ return Ack(M - 1, 1)
+ end
+ return Ack(M - 1, Ack(M, (N - 1)))
+end
+
+N = tonumber((arg and arg[1])) or 3
+M = tonumber((arg and arg[2])) or 8
+print(string.format("Ack(%d, %d) = %d\n", N, M, Ack(N,M)))
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback