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/backcall.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/backcall.yue')
-rw-r--r-- | spec/inputs/backcall.yue | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/spec/inputs/backcall.yue b/spec/inputs/backcall.yue new file mode 100644 index 0000000..bad3a56 --- /dev/null +++ b/spec/inputs/backcall.yue | |||
@@ -0,0 +1,153 @@ | |||
1 | |||
2 | {"abc", 123, 998} |> foreach print | ||
3 | |||
4 | {1,2,3} | ||
5 | |> map (x)-> x * 2 | ||
6 | |> filter (x)-> x > 4 | ||
7 | |> reduce 0, (a,b)-> a + b | ||
8 | |||
9 | |||
10 | [i |> tostring for i = 0,10] |> table.concat(",") |> print | ||
11 | |||
12 | b = 1 + 2 + (4 |> tostring |> print(1) or 123) | ||
13 | |||
14 | if x = 233 |> math.max 998 | ||
15 | print x | ||
16 | |||
17 | with b |> create? "new" | ||
18 | .value = 123 | ||
19 | print \work! | ||
20 | |||
21 | 123 |> f? | ||
22 | |||
23 | "abc" |> f1? |> f2? | ||
24 | |||
25 | c = "abc" |> f1? |> f2? | ||
26 | |||
27 | f = -> | ||
28 | arg |> x.y?\if | ||
29 | |||
30 | 998 |> func2 "abc", 233 |> func0 |> func1 | ||
31 | 998 |> func0("abc", 233) |> func1 |> func2 | ||
32 | |||
33 | 1 |> f 2, 3, 4, 5 | ||
34 | val(2) |> f 1, _, 3, 4, 5 | ||
35 | arr[3] |> f 1, 2, _, 4, 5 | ||
36 | |||
37 | a = {"1","2","3"} |> table.concat("") |> tonumber |> f1(1, 2, 3, _) |> f2(1, _, 3) | ||
38 | |||
39 | readFile("example.txt") |> | ||
40 | extract(_, language, {}) |> | ||
41 | parse(_, language) |> | ||
42 | emit |> | ||
43 | render |> | ||
44 | |||
45 | |||
46 | readFile("example.txt") \ | ||
47 | |> extract(_, language, {}) \ | ||
48 | |> parse(_, language) \ | ||
49 | |> emit \ | ||
50 | |> render \ | ||
51 | |||
52 | |||
53 | readFile "example.txt" | ||
54 | |> extract _, language, {} | ||
55 | |> parse _, language | ||
56 | |> emit | ||
57 | |> render | ||
58 | |||
59 | |||
60 | 123 |> not func! |> f | ||
61 | |||
62 | do | ||
63 | _1 = list{"abc","xyz","123"}\map"#"\value! | ||
64 | |> -func! | ||
65 | |> abc 123, _, "x" | ||
66 | |||
67 | global _2,_3,_4 = 1,2,3 | ||
68 | |> f | ||
69 | |||
70 | local _5 = v |> f1 1 | ||
71 | |> f2 2 | ||
72 | |> f3 3 | ||
73 | |> f4 4 | ||
74 | |||
75 | do | ||
76 | (x)<- map {1,2,3} | ||
77 | x * 2 | ||
78 | |||
79 | do | ||
80 | (x)<- map _,{1,2,3} | ||
81 | x * 2 | ||
82 | |||
83 | do | ||
84 | (x)<- filter _, do | ||
85 | (x)<- map _,{1,2,3,4} | ||
86 | x * 2 | ||
87 | x > 2 | ||
88 | |||
89 | do | ||
90 | (data)<- http?.get "ajaxtest" | ||
91 | body[".result"]\html data | ||
92 | (processed)<- http.post "ajaxprocess", data | ||
93 | body[".result"]\append processed | ||
94 | <- setTimeout 1000 | ||
95 | print "done" | ||
96 | |||
97 | do | ||
98 | <- syncStatus | ||
99 | (err,data="nil")<- loadAsync "file.moon" | ||
100 | if err | ||
101 | print err | ||
102 | return | ||
103 | (codes)<- compileAsync data | ||
104 | func = loadstring codes | ||
105 | func! | ||
106 | |||
107 | do | ||
108 | <- f1 | ||
109 | <- f2 | ||
110 | do | ||
111 | <- f3 | ||
112 | <- f4 | ||
113 | <- f5 | ||
114 | <- f6 | ||
115 | f7! | ||
116 | |||
117 | do | ||
118 | :result,:msg = do | ||
119 | (data)<- receiveAsync "filename.txt" | ||
120 | print data | ||
121 | (info)<- processAsync data | ||
122 | check info | ||
123 | print result,msg | ||
124 | |||
125 | totalSize = (for file in *files | ||
126 | (data)<- loadAsync file | ||
127 | addToCache file,data) |> reduce 0,(a,b)-> a+b | ||
128 | |||
129 | propA = do | ||
130 | (value)<= property => @_value | ||
131 | print "old value: #{@_value}" | ||
132 | print "new value: #{value}" | ||
133 | @_value = value | ||
134 | |||
135 | propB = do | ||
136 | <= property _, (value)=> | ||
137 | print "old value: #{@_value}" | ||
138 | print "new value: #{value}" | ||
139 | @_value = value | ||
140 | @_value | ||
141 | |||
142 | alert "hi" | ||
143 | |||
144 | x = 123 |> a |> b or 456 |> c |> d or a.if\then("abc") or a?.b\c?(123) or x\y | ||
145 | |||
146 | x1 = 3 * -4 |> f | ||
147 | |||
148 | x2 = 3 * -2 ^ 2 |> f | ||
149 | |||
150 | y = 1 + not # 2 |> (a ^ c) |> b(3,_) * 4 ^ -123 |> f |> f1 or 123 | ||
151 | |||
152 | nil | ||
153 | |||