-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathv4-test.jester
162 lines (131 loc) · 1.94 KB
/
v4-test.jester
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
foo = 0
foo = 100
bar = "green"
my_array = [1, 4, 3]
print("index 0 ", my_array[0])
print("index 1 ", my_array[1])
my_dict = {
a = 1,
b = 2 + 10 / 2,
c = 3
}
print(my_dict)
x = 3
my_array[x-1] = 10
print("index 2 ", my_array[2])
$["a"] = 10
$.b = 20
ary = [
1, 2,
3 ]
print(ary)
ary2 = [
]
print(ary2)
ary3 = [
"foo"
,
"bar"
,
"baz"
]
$foo = 10
print($)
print(ary3)
lambda1 = .{ x,y| x + y }
print(lambda1(10, 11))
def test_lambda(a, b) {
.{ x, y | a + b + x + y }
}
l = test_lambda(1, 2)
print(l(3, 4))
print(-+-+-5)
print(++++-5)
print(!5)
print(!!5)
print(~1)
if foo < 10 {
print("foo is less than 10")
} else if foo == 10 {
print("foo is 10")
} else if bar == "green" {
print("bar is green")
}
print("1 | 2 =", 1 | 2)
print("5 ^ 5 =", 5 ^ 5)
print("3 & 1 =", 3 & 1)
print("4 == 4", 4 == 4)
print("3 != 4", 3 != 4)
print("1 < 2", 1 < 2)
print("2 <= 2", 2 <= 2)
print("3 > 2", 3 > 2)
print("2 >= 2", 2 >= 2)
print("6 >> 1 =", 6 >> 1)
print("6 << 2 =", 6 << 2)
print("10 + 5 =", 10 + 5)
print("11 - 6 =", 11 - 6)
print("5 * 10 =", 5 * 10)
print("5 / 10 =", 5 / 10)
print("21 \\ 10 =", 21 \ 10)
print("10 ** 2 =", 10 ** 2)
print("21 % 10 =", 21 % 10)
print("a() && b() && c() =", a() && b())
print("a() || c() =", a() || b())
$foo = 10
print("$foo =", $foo)
print("foo =", foo)
c()
c()
print("foo =", foo)
def a() {
return true
}
def b() {
return 0
}
def c() {
foo = foo + 1
}
--a = b = 0xff
--b = b + 0b1100101
--
--print(a + b)
--print(1 + 2)
--print(10 + 4 - 4)
--
---- x = 0
---- while x < 10 {
---- print(x)
---- sleep(0.05)
---- x = x + 1
---- }
--
--def test_closure(x) {
-- y = 15
-- def foo {
-- print(x + y + a + b)
-- }
-- return foo
--}
--
--my_fn = test_closure(100)
--my_fn()
--
--
--def count_to(x, d) {
-- i = 0
-- while i < x {
-- print(i); sleep(d)
-- i = i + 1
-- }
--}
--
--t1 = spawn count_to(10, 0.1)
--t2 = spawn count_to(100, 0.01)
--t3 = spawn count_to(5, 0.2)
--
--wait(t1)
--wait(t2)
--wait(t3)
--
--print(303)--