aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/loops.yue
blob: 5cadbf0c910544f67fa921ed3e2a20a019d1892e (plain)
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198

for x=1,10
	print "yeah"

for x=1,#something
	print "yeah"

for y=100,60,-3
	print "count down", y

for a=1,10 do print "okay"

for a=1,10
	for b = 2,43
		print a,b

for i in iter
	for j in yeah
		x = 343 + i + j
		print i, j

for x in *something
	print x

for k,v in pairs hello do print k,v

for x in y, z
	print x

for x in y, z, k
	print x

for name, members in *modules
	print name, member

x = ->
	for x in y
		_ = y

hello = {1,2,3,4,5}

x = for y in *hello
	if y % 2 == 0
		y

x = ->
	for x in *hello
		_ = y

t = for i=10,20 do i * 2

hmm = 0
y = for j = 3,30, 8
	hmm += 1
	j * hmm

_ = ->
	for k=10,40
		_ = "okay"

_ = ->
	return for k=10,40
		"okay"

while true do print "name"

while 5 + 5
	print "okay world"
	working man

while also do
	i work too
	_ = "okay"

i = 0
x = while i < 10
	i += 1
	i

-- values that can't be coerced

x = for thing in *3
	y = "hello"
	break

x = for x=1,2
	y = "hello"
	y

-- continue

while true
	continue if false
	print "yes"
	break if true
	print "no"

for i = 1, 10
	while true
		if not true
			continue
		break

a = 1
repeat
	a += 1
	if a == 5
		continue
	if a == 6
		break
	print a
until a == 10

x = 0
repeat
	x += 1
	y = x
	continue if x < 5
	print y
until y == 10

a = 3
until a == 0
	a -= 1
done = false
until done do done = true
repeat
	print "hello"
until true
until done
	x = 10
	repeat
		x -= 1
	until x == 0
until cond
	print "okay"

for x=1,10
	continue if x > 3 and x < 7
	print x


list = for x=1,10
	continue if x > 3 and x < 7
	x


for a in *{1,2,3,4,5,6}
	continue if a == 1
	continue if a == 3
	print a



for x=1,10
	continue if x % 2 == 0
	for y = 2,12
		continue if y % 3 == 0


while true
	continue if false
	break

while true
	continue if false
	return 22

--

do
	xxx = {1,2,3,4}
	for thing in *xxx
		print thing

do
	for i = 1, 10
		repeat
			with? tb
				.a = 1
				continue if .b
				do
					if .c
						break
		until true
		switch x
			when 123
				break
			else
				continue
		if y
			continue
		else
			break
		do do do
			print i
			continue
		print "abc"