diff options
| author | Li Jin <dragon-fly@qq.com> | 2021-04-19 18:10:08 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2021-04-19 18:10:08 +0800 |
| commit | 7ac784e73b026ce7e17babb2f0b819864fd898b0 (patch) | |
| tree | 244a39123a4789a04fb577d6956bdb461509a153 /spec/inputs/pipe.yue | |
| parent | ce9f6632635222b38ef0b37b4b1273da4a1877b4 (diff) | |
| download | yuescript-7ac784e73b026ce7e17babb2f0b819864fd898b0.tar.gz yuescript-7ac784e73b026ce7e17babb2f0b819864fd898b0.tar.bz2 yuescript-7ac784e73b026ce7e17babb2f0b819864fd898b0.zip | |
rename BackcallOperator to PipeOperator.
Diffstat (limited to 'spec/inputs/pipe.yue')
| -rw-r--r-- | spec/inputs/pipe.yue | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/spec/inputs/pipe.yue b/spec/inputs/pipe.yue new file mode 100644 index 0000000..7e33422 --- /dev/null +++ b/spec/inputs/pipe.yue | |||
| @@ -0,0 +1,84 @@ | |||
| 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 | x = 123 |> a |> b or 456 |> c |> d or a.if\then("abc") or a?.b\c?(123) or x\y | ||
| 76 | |||
| 77 | x1 = 3 * -4 |> f | ||
| 78 | |||
| 79 | x2 = 3 * -2 ^ 2 |> f | ||
| 80 | |||
| 81 | y = 1 + not # 2 |> (a ^ c) |> b(3,_) * 4 ^ -123 |> f |> f1 or 123 | ||
| 82 | |||
| 83 | nil | ||
| 84 | |||
