| 1 |
Source: function(x) { return x*2; } |
| 2 |
Call: f(7) |
| 3 |
Result: 14 |
| 4 |
|
| 5 |
Source: function(x, x, x) { return x*x; } |
| 6 |
Call: f(7) |
| 7 |
Compiler error |
| 8 |
error: formal parameter "x" defined more than once |
| 9 |
error: formal parameter "x" defined more than once |
| 10 |
|
| 11 |
Source: function(x, p, y) { return x.(p)(y + 1000); } |
| 12 |
Call: f(test1, &m1, 456) |
| 13 |
Result: greetings from test1.m1(1456)! |
| 14 |
|
| 15 |
Source: function(x, y) { return x.m1(y + 1000); } |
| 16 |
Call: f(test1, 678) |
| 17 |
Result: greetings from test1.m1(1678)! |
| 18 |
|
| 19 |
Source: function(x, y) { return x.mUndef(y + 1000); } |
| 20 |
Call: f(test1, 678) |
| 21 |
Compiler error |
| 22 |
error: undefined symbol "mUndef" |
| 23 |
|
| 24 |
Source: test1.m1(123); |
| 25 |
Call: f() |
| 26 |
Result: greetings from test1.m1(123)! |
| 27 |
|
| 28 |
Source: test2.m1(123); |
| 29 |
Call: f() |
| 30 |
Result: greetings from test2.m1(123)! |
| 31 |
|
| 32 |
Source: function(x) { return test2.m1(x + 1000); } |
| 33 |
Call: f(789) |
| 34 |
Result: greetings from test2.m1(1789)! |
| 35 |
|
| 36 |
Source: function(x) { return f1(x + 1000); } |
| 37 |
Call: f(654) |
| 38 |
Result: Greetings from f1(1654)! |
| 39 |
|
| 40 |
Source: new BigNumber('123.456'); |
| 41 |
Call: f() |
| 42 |
Result: 123.456 |
| 43 |
|
| 44 |
Source: function(x) { local a = x*2, f = {x, y: 'anon f! x=<<x>>, y=<<y>>, |
| 45 |
a=<<a>>'}; a += 1; return f; } |
| 46 |
Call: f(135)(7, 8) |
| 47 |
Result: anon f! x=7, y=8, a=271 |
| 48 |
|
| 49 |
Source: function(x, y) { local f = {: ++x, ++y, 'this is anon 1: x=<<x>>, |
| 50 |
y=<<y>>' }; local g = {: ++x, ++y, 'this is anon 2: x=<<x>>, y=<<y>>' }; return |
| 51 |
[f, g]; } |
| 52 |
Call: testAnon(f) |
| 53 |
Result: l = f(123, 456): |
| 54 |
type(l)=10, l.length=2 |
| 55 |
type(l[1])=5, type(l[2])=5 |
| 56 |
l[1]()=this is anon 1: x=124, y=457, l[2]()=this is anon 2: x=125, y=458 |
| 57 |
|
| 58 |
Source: function(a:, b:) { return a+b*1000; } |
| 59 |
Call: f(b:123, a:789) |
| 60 |
Result: 123789 |
| 61 |
|
| 62 |
Source: function() { local lst = [10, 20, 30, 40, 50]; local sum = 0; for |
| 63 |
(local i in lst) sum += i; return sum; } |
| 64 |
Call: f() |
| 65 |
Result: 150 |
| 66 |
|
| 67 |
Source: function() { nameTest(b:123, a:'hello'); } |
| 68 |
Call: f() |
| 69 |
Result: Named argument test: a=hello, b=123 |
| 70 |
|
| 71 |
Source: function() { local obj = new Thing('test'); obj.desc; } |
| 72 |
Call: f() |
| 73 |
Result: This is a Thing whose name is 'test'! |
| 74 |
|
| 75 |
Source: function(cnt) { for (local i in 1..cnt) "[<<i>>] Embedded item number |
| 76 |
<<one of>>one<<or>>two<<or >>three<<or>>four<<cycling>>... "; } |
| 77 |
Call: f(10) |
| 78 |
Result: [1] Embedded item number one... [2] Embedded item number two... [3] |
| 79 |
Embedded item number three... [4] Embedded item number four... [5] Embedded |
| 80 |
item number one... [6] Embedded item number two... [7] Embedded item number |
| 81 |
three... [8] Embedded item number four... [9] Embedded item number one... [10] |
| 82 |
Embedded item number two... |
| 83 |
|
| 84 |
Source: function([lst]) { for (local x in lst) "Embedded if test: x=<<x>>, |
| 85 |
which is << if x > 5>>greater than<<else if x < 5>>less than<<else |
| 86 |
>>exactly<<end>> five... "; } |
| 87 |
Call: f(7, 3, 5, 9, 4) |
| 88 |
Result: Embedded if test: x=7, which is greater than five... Embedded if test: |
| 89 |
x=3, which is less than five... Embedded if test: x=5, which is exactly five... |
| 90 |
Embedded if test: x=9, which is greater than five... Embedded if test: x=4, |
| 91 |
which is less than five... |
| 92 |
|
| 93 |
Source: function(x) { return square(x); } |
| 94 |
Call: f(11) |
| 95 |
Result: 121 |
| 96 |
|
| 97 |
Source: function(x, y) { return RTEST(x+1, y+1); } |
| 98 |
Call: f(101, 202) |
| 99 |
Result: This is RTEST(102, 203)!!! |
| 100 |
|
| 101 |
Source: function() { return i; } |
| 102 |
Call: localtest() |
| 103 |
Result: this is the 'i' value! |
| 104 |
|
| 105 |
Source: function() { return i; } |
| 106 |
Call: localtest() |
| 107 |
Result: another 'i' value! |
| 108 |
|
| 109 |
Source: function() { local orig = i; i += ' *MODIFIED!*'; return orig; } |
| 110 |
Call: localtest2_part1() |
| 111 |
Result: original 'i' value |
| 112 |
|
| 113 |
Source: function() { return i; } |
| 114 |
Call: localtest2_part2() |
| 115 |
Result: original 'i' value *MODIFIED!* |
| 116 |
|
| 117 |
Source: function() { local orig = i; i += ' [modified by dynfunc]'; return |
| 118 |
orig; } |
| 119 |
Call: localtest3_part1() |
| 120 |
Result: first i value |
| 121 |
|
| 122 |
Source: function() { return i; } |
| 123 |
Call: localtest3_part2() |
| 124 |
Result: first i value [modified by dynfunc] [modified by anon fn] |
| 125 |
|
| 126 |
|
| 127 |
localtest4: |
| 128 |
. test(1): before cnt=0, after cnt=0 |
| 129 |
. test(2): before cnt=0, after cnt=0 |
| 130 |
. test(3): before cnt=0, after cnt=0 |
| 131 |
. test(4): before cnt=0, after cnt=1 |
| 132 |
. test(5): before cnt=1, after cnt=2 |
| 133 |
|
| 134 |
(T3VM) Memory blocks still in use: |
| 135 |
|
| 136 |
Total blocks in use: 0 |