aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/backcall.mp
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2020-10-08 13:01:18 +0800
committerLi Jin <dragon-fly@qq.com>2020-10-08 13:01:18 +0800
commit97bbe98289fb74c7cf2d9793b80a1a27b4146045 (patch)
tree4bee0dded55bad28f6822b6e2dd3ea5251c66ae2 /spec/inputs/backcall.mp
parent5b656d2913e4f9f0017698ec835ce4ddda1dc81f (diff)
downloadyuescript-97bbe98289fb74c7cf2d9793b80a1a27b4146045.tar.gz
yuescript-97bbe98289fb74c7cf2d9793b80a1a27b4146045.tar.bz2
yuescript-97bbe98289fb74c7cf2d9793b80a1a27b4146045.zip
change file extension moonp.
Diffstat (limited to 'spec/inputs/backcall.mp')
-rw-r--r--spec/inputs/backcall.mp117
1 files changed, 117 insertions, 0 deletions
diff --git a/spec/inputs/backcall.mp b/spec/inputs/backcall.mp
new file mode 100644
index 0000000..a648b16
--- /dev/null
+++ b/spec/inputs/backcall.mp
@@ -0,0 +1,117 @@
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 |> print
9
10[i |> tostring for i = 0,10] |> table.concat(",") |> print
11
12b = 1 + 2 + (4 |> tostring |> print(1) or 123)
13
14if x = 233 |> math.max 998
15 print x
16
17with b |> create? "new"
18 .value = 123
19 print \work!
20
21123 |> f?
22
23"abc" |> f1? |> f2?
24
25c = "abc" |> f1? |> f2?
26
27f = ->
28 arg |> x.y?\if
29
30998 |> func2 "abc", 233 |> func0 |> func1
31998 |> func0("abc", 233) |> func1 |> func2
32
331 |> f 2, 3, 4, 5
34val(2) |> f 1, _, 3, 4, 5
35arr[3] |> f 1, 2, _, 4, 5
36
37a = {"1","2","3"} |> table.concat("") |> tonumber |> f1(1, 2, 3, _) |> f2(1, _, 3)
38
39do
40 (x)<- map {1,2,3}
41 x * 2
42
43do
44 (x)<- map _,{1,2,3}
45 x * 2
46
47do
48 (x)<- filter _, do
49 (x)<- map _,{1,2,3,4}
50 x * 2
51 x > 2
52
53do
54 (data)<- http?.get "ajaxtest"
55 body[".result"]\html data
56 (processed)<- http.post "ajaxprocess", data
57 body[".result"]\append processed
58 <- setTimeout 1000
59 print "done"
60
61do
62 <- syncStatus
63 (err,data="nil")<- loadAsync "file.moon"
64 if err
65 print err
66 return
67 (codes)<- compileAsync data
68 func = loadstring codes
69 func!
70
71do
72 <- f1
73 <- f2
74 do
75 <- f3
76 <- f4
77 <- f5
78 <- f6
79 f7!
80
81do
82 :result,:msg = do
83 (data)<- receiveAsync "filename.txt"
84 print data
85 (info)<- processAsync data
86 check info
87 print result,msg
88
89 totalSize = (for file in *files
90 (data)<- loadAsync file
91 addToCache file,data) |> reduce 0,(a,b)-> a+b
92
93propA = do
94 (value)<= property => @_value
95 print "old value: #{@_value}"
96 print "new value: #{value}"
97 @_value = value
98
99propB = do
100 <= property _, (value)=>
101 print "old value: #{@_value}"
102 print "new value: #{value}"
103 @_value = value
104 @_value
105
106alert "hi"
107
108x = 123 |> a |> b or 456 |> c |> d or a.if\then("abc") or a?.b\c?(123) or x\y
109
110x1 = 3 * -4 |> f
111
112x2 = 3 * -2 ^ 2 |> f
113
114y = 1 + not # 2 |> (a ^ c) |> b(3,_) * 4 ^ -123 |> f |> f1 or 123
115
116nil
117