fixed newslot in table.cpp, that would return false, even though the slot was correct...
[vox.git] / examples / ackermann.vx
blobd6468fd2c569319420f8419decfcf95bd5346293
1 \r
2 function Ack(M, N)\r
3 {\r
4     if(M == 0)\r
5         return  N + 1\r
6     if(N == 0)\r
7         return Ack(M - 1, 1)\r
8     return Ack(M - 1, Ack(M, (N - 1)))\r
9 }\r
12 local m = 3, n = 1\r
13 if(system.argv.len() > 2)\r
14 {\r
15     try\r
16     {\r
17         m = system.argv[1].tointeger();\r
18         n = system.argv[2].tointeger()\r
19         if(n < 1)\r
20             n = 1;\r
21     }\r
22     catch(err)\r
23     {\r
24         io.stderr.write("Error = %s".fmt(err))\r
25     }\r
26 }\r
28 // first write the definition to stdout, then the result\r
29 print("Ack(M=%d, N=%d) = ".fmt(m, n)); io.stdout.flush(); println(Ack(m, n))\r