The Squirrel interpreter. See http://www.squirrel-lang.org/

Dependents:   Squirrel

Committer:
jhnwkmn
Date:
Tue Dec 16 10:20:34 2014 +0000
Revision:
0:97a4f8cc534c
Initial import of Squirrel.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jhnwkmn 0:97a4f8cc534c 1 /*
jhnwkmn 0:97a4f8cc534c 2 *
jhnwkmn 0:97a4f8cc534c 3 * Original Javascript version by David Hedbor(http://www.bagley.org/~doug/shootout/)
jhnwkmn 0:97a4f8cc534c 4 *
jhnwkmn 0:97a4f8cc534c 5 */
jhnwkmn 0:97a4f8cc534c 6
jhnwkmn 0:97a4f8cc534c 7 function Ack(M, N) {
jhnwkmn 0:97a4f8cc534c 8 if (M == 0) return( N + 1 );
jhnwkmn 0:97a4f8cc534c 9 if (N == 0) return( Ack(M - 1, 1) );
jhnwkmn 0:97a4f8cc534c 10 return( Ack(M - 1, Ack(M, (N - 1))) );
jhnwkmn 0:97a4f8cc534c 11 }
jhnwkmn 0:97a4f8cc534c 12
jhnwkmn 0:97a4f8cc534c 13 local n;
jhnwkmn 0:97a4f8cc534c 14
jhnwkmn 0:97a4f8cc534c 15 if(vargv.len()!=0) {
jhnwkmn 0:97a4f8cc534c 16 n = vargv[0].tointeger();
jhnwkmn 0:97a4f8cc534c 17 if(n < 1) n = 1;
jhnwkmn 0:97a4f8cc534c 18 } else {
jhnwkmn 0:97a4f8cc534c 19 n = 1;
jhnwkmn 0:97a4f8cc534c 20 }
jhnwkmn 0:97a4f8cc534c 21 print("n="+n+"\n");
jhnwkmn 0:97a4f8cc534c 22 print("Ack(3,"+ n+ "):"+ Ack(3, n));
jhnwkmn 0:97a4f8cc534c 23