aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/loops.mp
diff options
context:
space:
mode:
Diffstat (limited to 'spec/inputs/loops.mp')
-rw-r--r--spec/inputs/loops.mp142
1 files changed, 142 insertions, 0 deletions
diff --git a/spec/inputs/loops.mp b/spec/inputs/loops.mp
new file mode 100644
index 0000000..24d960f
--- /dev/null
+++ b/spec/inputs/loops.mp
@@ -0,0 +1,142 @@
1
2for x=1,10
3 print "yeah"
4
5for x=1,#something
6 print "yeah"
7
8for y=100,60,-3
9 print "count down", y
10
11for a=1,10 do print "okay"
12
13for a=1,10
14 for b = 2,43
15 print a,b
16
17for i in iter
18 for j in yeah
19 x = 343 + i + j
20 print i, j
21
22for x in *something
23 print x
24
25for k,v in pairs hello do print k,v
26
27for x in y, z
28 print x
29
30for x in y, z, k
31 print x
32
33
34x = ->
35 for x in y
36 _ = y
37
38hello = {1,2,3,4,5}
39
40x = for y in *hello
41 if y % 2 == 0
42 y
43
44x = ->
45 for x in *hello
46 _ = y
47
48t = for i=10,20 do i * 2
49
50hmm = 0
51y = for j = 3,30, 8
52 hmm += 1
53 j * hmm
54
55_ = ->
56 for k=10,40
57 _ = "okay"
58
59_ = ->
60 return for k=10,40
61 "okay"
62
63while true do print "name"
64
65while 5 + 5
66 print "okay world"
67 working man
68
69while also do
70 i work too
71 _ = "okay"
72
73i = 0
74x = while i < 10
75 i += 1
76
77-- values that can'e be coerced
78
79x = for thing in *3
80 y = "hello"
81
82x = for x=1,2
83 y = "hello"
84
85
86-- continue
87
88while true
89 continue if false
90 print "yes"
91 break if true
92 print "no"
93
94a = 1
95repeat
96 a += 1
97 if a == 5
98 continue
99 if a == 6
100 break
101 print a
102until a == 10
103
104for x=1,10
105 continue if x > 3 and x < 7
106 print x
107
108
109list = for x=1,10
110 continue if x > 3 and x < 7
111 x
112
113
114for a in *{1,2,3,4,5,6}
115 continue if a == 1
116 continue if a == 3
117 print a
118
119
120
121for x=1,10
122 continue if x % 2 == 0
123 for y = 2,12
124 continue if y % 3 == 0
125
126
127while true
128 continue if false
129 break
130
131while true
132 continue if false
133 return 22
134
135--
136
137do
138 xxx = {1,2,3,4}
139 for thing in *xxx
140 print thing
141
142