diff options
author | Li Jin <dragon-fly@qq.com> | 2021-02-17 11:22:07 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2021-02-17 11:22:07 +0800 |
commit | 7066392d1c974065181d95d93274136dcd625d43 (patch) | |
tree | cf51eafc2c52cbc12246a306bca172d799193d30 /spec/inputs/loops.yue | |
parent | 90cd12ad9ef465f3e435e1bd034dcfbe4e19d016 (diff) | |
download | yuescript-7066392d1c974065181d95d93274136dcd625d43.tar.gz yuescript-7066392d1c974065181d95d93274136dcd625d43.tar.bz2 yuescript-7066392d1c974065181d95d93274136dcd625d43.zip |
stop reusing variables, rename project.
Diffstat (limited to 'spec/inputs/loops.yue')
-rw-r--r-- | spec/inputs/loops.yue | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/spec/inputs/loops.yue b/spec/inputs/loops.yue new file mode 100644 index 0000000..8946a2f --- /dev/null +++ b/spec/inputs/loops.yue | |||
@@ -0,0 +1,148 @@ | |||
1 | |||
2 | for x=1,10 | ||
3 | print "yeah" | ||
4 | |||
5 | for x=1,#something | ||
6 | print "yeah" | ||
7 | |||
8 | for y=100,60,-3 | ||
9 | print "count down", y | ||
10 | |||
11 | for a=1,10 do print "okay" | ||
12 | |||
13 | for a=1,10 | ||
14 | for b = 2,43 | ||
15 | print a,b | ||
16 | |||
17 | for i in iter | ||
18 | for j in yeah | ||
19 | x = 343 + i + j | ||
20 | print i, j | ||
21 | |||
22 | for x in *something | ||
23 | print x | ||
24 | |||
25 | for k,v in pairs hello do print k,v | ||
26 | |||
27 | for x in y, z | ||
28 | print x | ||
29 | |||
30 | for x in y, z, k | ||
31 | print x | ||
32 | |||
33 | |||
34 | x = -> | ||
35 | for x in y | ||
36 | _ = y | ||
37 | |||
38 | hello = {1,2,3,4,5} | ||
39 | |||
40 | x = for y in *hello | ||
41 | if y % 2 == 0 | ||
42 | y | ||
43 | |||
44 | x = -> | ||
45 | for x in *hello | ||
46 | _ = y | ||
47 | |||
48 | t = for i=10,20 do i * 2 | ||
49 | |||
50 | hmm = 0 | ||
51 | y = 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 | |||
63 | while true do print "name" | ||
64 | |||
65 | while 5 + 5 | ||
66 | print "okay world" | ||
67 | working man | ||
68 | |||
69 | while also do | ||
70 | i work too | ||
71 | _ = "okay" | ||
72 | |||
73 | i = 0 | ||
74 | x = while i < 10 | ||
75 | i += 1 | ||
76 | |||
77 | -- values that can'e be coerced | ||
78 | |||
79 | x = for thing in *3 | ||
80 | y = "hello" | ||
81 | |||
82 | x = for x=1,2 | ||
83 | y = "hello" | ||
84 | |||
85 | |||
86 | -- continue | ||
87 | |||
88 | while true | ||
89 | continue if false | ||
90 | print "yes" | ||
91 | break if true | ||
92 | print "no" | ||
93 | |||
94 | for i = 1, 10 | ||
95 | while true | ||
96 | if not true | ||
97 | continue | ||
98 | break | ||
99 | |||
100 | a = 1 | ||
101 | repeat | ||
102 | a += 1 | ||
103 | if a == 5 | ||
104 | continue | ||
105 | if a == 6 | ||
106 | break | ||
107 | print a | ||
108 | until a == 10 | ||
109 | |||
110 | for x=1,10 | ||
111 | continue if x > 3 and x < 7 | ||
112 | print x | ||
113 | |||
114 | |||
115 | list = for x=1,10 | ||
116 | continue if x > 3 and x < 7 | ||
117 | x | ||
118 | |||
119 | |||
120 | for a in *{1,2,3,4,5,6} | ||
121 | continue if a == 1 | ||
122 | continue if a == 3 | ||
123 | print a | ||
124 | |||
125 | |||
126 | |||
127 | for x=1,10 | ||
128 | continue if x % 2 == 0 | ||
129 | for y = 2,12 | ||
130 | continue if y % 3 == 0 | ||
131 | |||
132 | |||
133 | while true | ||
134 | continue if false | ||
135 | break | ||
136 | |||
137 | while true | ||
138 | continue if false | ||
139 | return 22 | ||
140 | |||
141 | -- | ||
142 | |||
143 | do | ||
144 | xxx = {1,2,3,4} | ||
145 | for thing in *xxx | ||
146 | print thing | ||
147 | |||
148 | |||