aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/lists.yue
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-02-17 11:22:07 +0800
committerLi Jin <dragon-fly@qq.com>2021-02-17 11:22:07 +0800
commit7066392d1c974065181d95d93274136dcd625d43 (patch)
treecf51eafc2c52cbc12246a306bca172d799193d30 /spec/inputs/lists.yue
parent90cd12ad9ef465f3e435e1bd034dcfbe4e19d016 (diff)
downloadyuescript-7066392d1c974065181d95d93274136dcd625d43.tar.gz
yuescript-7066392d1c974065181d95d93274136dcd625d43.tar.bz2
yuescript-7066392d1c974065181d95d93274136dcd625d43.zip
stop reusing variables, rename project.
Diffstat (limited to 'spec/inputs/lists.yue')
-rw-r--r--spec/inputs/lists.yue72
1 files changed, 72 insertions, 0 deletions
diff --git a/spec/inputs/lists.yue b/spec/inputs/lists.yue
new file mode 100644
index 0000000..15eb9ab
--- /dev/null
+++ b/spec/inputs/lists.yue
@@ -0,0 +1,72 @@
1
2hi = [x*2 for _, x in ipairs{1,2,3,4}]
3
4items = {1,2,3,4,5,6}
5
6_ = [z for z in ipairs items when z > 4]
7
8rad = [{a} for a in ipairs {
9 1,2,3,4,5,6,
10} when good_number a]
11
12
13_ = [z for z in items for j in list when z > 4]
14
15require "util"
16
17dump = (x) -> print util.dump x
18
19range = (count) ->
20 i = 0
21 return coroutine.wrap ->
22 while i < count
23 coroutine.yield i
24 i = i + 1
25
26dump [x for x in range 10]
27dump [{x, y} for x in range 5 when x > 2 for y in range 5]
28
29things = [x + y for x in range 10 when x > 5 for y in range 10 when y > 7]
30
31print x,y for x in ipairs{1,2,4} for y in ipairs{1,2,3} when x != 2
32
33print "hello", x for x in items
34
35_ = [x for x in x]
36x = [x for x in x]
37
38print x,y for x in ipairs{1,2,4} for y in ipairs{1,2,3} when x != 2
39
40double = [x*2 for x in *items]
41
42print x for x in *double
43
44cut = [x for x in *items when x > 3]
45
46hello = [x + y for x in *items for y in *items]
47
48print z for z in *hello
49
50
51-- slice
52x = {1, 2, 3, 4, 5, 6, 7}
53print y for y in *x[2,-5,2]
54print y for y in *x[,3]
55print y for y in *x[2,]
56print y for y in *x[,,2]
57print y for y in *x[2,,2]
58
59a, b, c = 1, 5, 2
60print y for y in *x[a,b,c]
61
62
63normal = (hello) ->
64 [x for x in yeah]
65
66
67test = x 1,2,3,4,5
68print thing for thing in *test
69
70-> a = b for row in *rows
71
72