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

Dependents:   Squirrel

Committer:
jhnwkmn
Date:
Tue Dec 16 11:39:42 2014 +0000
Revision:
3:7268a3ceaffc
Parent:
0:97a4f8cc534c
Accepts \r as line terminator as well.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jhnwkmn 0:97a4f8cc534c 1 local arr=["one","two","three"]
jhnwkmn 0:97a4f8cc534c 2
jhnwkmn 0:97a4f8cc534c 3 ::print("FOREACH\n");
jhnwkmn 0:97a4f8cc534c 4
jhnwkmn 0:97a4f8cc534c 5 foreach(i,val in arr)
jhnwkmn 0:97a4f8cc534c 6 {
jhnwkmn 0:97a4f8cc534c 7 ::print("index ["+i+"]="+val+"\n");
jhnwkmn 0:97a4f8cc534c 8 }
jhnwkmn 0:97a4f8cc534c 9
jhnwkmn 0:97a4f8cc534c 10 ::print("FOR\n");
jhnwkmn 0:97a4f8cc534c 11
jhnwkmn 0:97a4f8cc534c 12 for(local i=0;i<arr.len();i+=1)
jhnwkmn 0:97a4f8cc534c 13 {
jhnwkmn 0:97a4f8cc534c 14 ::print("index ["+i+"]="+arr[i]+"\n");
jhnwkmn 0:97a4f8cc534c 15 }
jhnwkmn 0:97a4f8cc534c 16
jhnwkmn 0:97a4f8cc534c 17 ::print("WHILE\n");
jhnwkmn 0:97a4f8cc534c 18
jhnwkmn 0:97a4f8cc534c 19 local i=0;
jhnwkmn 0:97a4f8cc534c 20 while(i<arr.len())
jhnwkmn 0:97a4f8cc534c 21 {
jhnwkmn 0:97a4f8cc534c 22 ::print("index ["+i+"]="+arr[i]+"\n");
jhnwkmn 0:97a4f8cc534c 23 i+=1;
jhnwkmn 0:97a4f8cc534c 24 }
jhnwkmn 0:97a4f8cc534c 25 ::print("DO WHILE\n");
jhnwkmn 0:97a4f8cc534c 26
jhnwkmn 0:97a4f8cc534c 27 local i=0;
jhnwkmn 0:97a4f8cc534c 28 do
jhnwkmn 0:97a4f8cc534c 29 {
jhnwkmn 0:97a4f8cc534c 30 ::print("index ["+i+"]="+arr[i]+"\n");
jhnwkmn 0:97a4f8cc534c 31 i+=1;
jhnwkmn 0:97a4f8cc534c 32 }while(i<arr.len());