diff options
| author | Li Jin <dragon-fly@qq.com> | 2020-10-08 13:01:18 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2020-10-08 13:01:18 +0800 |
| commit | 97bbe98289fb74c7cf2d9793b80a1a27b4146045 (patch) | |
| tree | 4bee0dded55bad28f6822b6e2dd3ea5251c66ae2 /spec/inputs/backcall.mp | |
| parent | 5b656d2913e4f9f0017698ec835ce4ddda1dc81f (diff) | |
| download | yuescript-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.mp | 117 |
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 | |||
| 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 | do | ||
| 40 | (x)<- map {1,2,3} | ||
| 41 | x * 2 | ||
| 42 | |||
| 43 | do | ||
| 44 | (x)<- map _,{1,2,3} | ||
| 45 | x * 2 | ||
| 46 | |||
| 47 | do | ||
| 48 | (x)<- filter _, do | ||
| 49 | (x)<- map _,{1,2,3,4} | ||
| 50 | x * 2 | ||
| 51 | x > 2 | ||
| 52 | |||
| 53 | do | ||
| 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 | |||
| 61 | do | ||
| 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 | |||
| 71 | do | ||
| 72 | <- f1 | ||
| 73 | <- f2 | ||
| 74 | do | ||
| 75 | <- f3 | ||
| 76 | <- f4 | ||
| 77 | <- f5 | ||
| 78 | <- f6 | ||
| 79 | f7! | ||
| 80 | |||
| 81 | do | ||
| 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 | |||
| 93 | propA = do | ||
| 94 | (value)<= property => @_value | ||
| 95 | print "old value: #{@_value}" | ||
| 96 | print "new value: #{value}" | ||
| 97 | @_value = value | ||
| 98 | |||
| 99 | propB = do | ||
| 100 | <= property _, (value)=> | ||
| 101 | print "old value: #{@_value}" | ||
| 102 | print "new value: #{value}" | ||
| 103 | @_value = value | ||
| 104 | @_value | ||
| 105 | |||
| 106 | alert "hi" | ||
| 107 | |||
| 108 | x = 123 |> a |> b or 456 |> c |> d or a.if\then("abc") or a?.b\c?(123) or x\y | ||
| 109 | |||
| 110 | x1 = 3 * -4 |> f | ||
| 111 | |||
| 112 | x2 = 3 * -2 ^ 2 |> f | ||
| 113 | |||
| 114 | y = 1 + not # 2 |> (a ^ c) |> b(3,_) * 4 ^ -123 |> f |> f1 or 123 | ||
| 115 | |||
| 116 | nil | ||
| 117 | |||
