The Squirrel interpreter. See http://www.squirrel-lang.org/
Diff: samples/ackermann.nut
- Revision:
- 0:97a4f8cc534c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/ackermann.nut Tue Dec 16 10:20:34 2014 +0000 @@ -0,0 +1,23 @@ +/* +* +* Original Javascript version by David Hedbor(http://www.bagley.org/~doug/shootout/) +* +*/ + +function Ack(M, N) { + if (M == 0) return( N + 1 ); + if (N == 0) return( Ack(M - 1, 1) ); + return( Ack(M - 1, Ack(M, (N - 1))) ); +} + +local n; + +if(vargv.len()!=0) { + n = vargv[0].tointeger(); + if(n < 1) n = 1; +} else { + n = 1; +} +print("n="+n+"\n"); +print("Ack(3,"+ n+ "):"+ Ack(3, n)); +