The Squirrel interpreter. See http://www.squirrel-lang.org/
samples/flow.nut@0:97a4f8cc534c, 2014-12-16 (annotated)
- Committer:
- jhnwkmn
- Date:
- Tue Dec 16 10:20:34 2014 +0000
- Revision:
- 0:97a4f8cc534c
Initial import of Squirrel.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jhnwkmn | 0:97a4f8cc534c | 1 | function min(x,y) |
jhnwkmn | 0:97a4f8cc534c | 2 | return x<y?x:y; |
jhnwkmn | 0:97a4f8cc534c | 3 | |
jhnwkmn | 0:97a4f8cc534c | 4 | function max(x,y) |
jhnwkmn | 0:97a4f8cc534c | 5 | return x>y?x:y; |
jhnwkmn | 0:97a4f8cc534c | 6 | |
jhnwkmn | 0:97a4f8cc534c | 7 | if(min(100,200)>max(50,20)) |
jhnwkmn | 0:97a4f8cc534c | 8 | print("I'm useless statement just to show up the if/else\n"); |
jhnwkmn | 0:97a4f8cc534c | 9 | else |
jhnwkmn | 0:97a4f8cc534c | 10 | print("squirrel!!\n"); |
jhnwkmn | 0:97a4f8cc534c | 11 | |
jhnwkmn | 0:97a4f8cc534c | 12 | print("\n") |
jhnwkmn | 0:97a4f8cc534c | 13 | |
jhnwkmn | 0:97a4f8cc534c | 14 | function typy(obj) |
jhnwkmn | 0:97a4f8cc534c | 15 | { |
jhnwkmn | 0:97a4f8cc534c | 16 | switch(typeof obj) |
jhnwkmn | 0:97a4f8cc534c | 17 | { |
jhnwkmn | 0:97a4f8cc534c | 18 | case "integer": |
jhnwkmn | 0:97a4f8cc534c | 19 | case "float": |
jhnwkmn | 0:97a4f8cc534c | 20 | return "is a number"; |
jhnwkmn | 0:97a4f8cc534c | 21 | case "table": |
jhnwkmn | 0:97a4f8cc534c | 22 | case "array": |
jhnwkmn | 0:97a4f8cc534c | 23 | return "is a container"; |
jhnwkmn | 0:97a4f8cc534c | 24 | default: |
jhnwkmn | 0:97a4f8cc534c | 25 | return "is other stuff" |
jhnwkmn | 0:97a4f8cc534c | 26 | } |
jhnwkmn | 0:97a4f8cc534c | 27 | } |
jhnwkmn | 0:97a4f8cc534c | 28 | |
jhnwkmn | 0:97a4f8cc534c | 29 | local a=1,b={},c=function(a,b){return a+b;} |
jhnwkmn | 0:97a4f8cc534c | 30 | |
jhnwkmn | 0:97a4f8cc534c | 31 | print("a "+typy(a)+"\n"); |
jhnwkmn | 0:97a4f8cc534c | 32 | print("b "+typy(b)+"\n"); |
jhnwkmn | 0:97a4f8cc534c | 33 | print("c "+typy(c)+"\n"); |