diff options
| author | Li Jin <dragon-fly@qq.com> | 2025-05-22 09:07:37 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2025-05-22 09:07:37 +0800 |
| commit | a8926771f1ae025d7bb7d39a33effa92b49393cc (patch) | |
| tree | d23aafd9bc7a18d9a80c5ae84290d25d07aa74d1 /doc | |
| parent | b21621692e877e5a44508b90049c2bc75091ebac (diff) | |
| download | yuescript-a8926771f1ae025d7bb7d39a33effa92b49393cc.tar.gz yuescript-a8926771f1ae025d7bb7d39a33effa92b49393cc.tar.bz2 yuescript-a8926771f1ae025d7bb7d39a33effa92b49393cc.zip | |
Updated docs. [skip CI]
Diffstat (limited to 'doc')
| -rwxr-xr-x | doc/docs/doc/README.md | 10 | ||||
| -rwxr-xr-x | doc/docs/zh/doc/README.md | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md index 4a408fe..ba69c80 100755 --- a/doc/docs/doc/README.md +++ b/doc/docs/doc/README.md | |||
| @@ -74,6 +74,16 @@ inventory = | |||
| 74 | * name: "bread" | 74 | * name: "bread" |
| 75 | count: 3 | 75 | count: 3 |
| 76 | 76 | ||
| 77 | -- list comprehension | ||
| 78 | map = (arr, action) -> | ||
| 79 | [action item for item in *arr] | ||
| 80 | |||
| 81 | filter = (arr, cond) -> | ||
| 82 | [item for item in *arr when cond item] | ||
| 83 | |||
| 84 | reduce = (arr, init, action): init -> | ||
| 85 | init = action init, item for item in *arr | ||
| 86 | |||
| 77 | -- pipe operator | 87 | -- pipe operator |
| 78 | [1, 2, 3] | 88 | [1, 2, 3] |
| 79 | |> map (x) -> x * 2 | 89 | |> map (x) -> x * 2 |
diff --git a/doc/docs/zh/doc/README.md b/doc/docs/zh/doc/README.md index d7b8361..c106ad5 100755 --- a/doc/docs/zh/doc/README.md +++ b/doc/docs/zh/doc/README.md | |||
| @@ -74,6 +74,16 @@ inventory = | |||
| 74 | * name: "bread" | 74 | * name: "bread" |
| 75 | count: 3 | 75 | count: 3 |
| 76 | 76 | ||
| 77 | -- 列表推导 | ||
| 78 | map = (arr, action) -> | ||
| 79 | [action item for item in *arr] | ||
| 80 | |||
| 81 | filter = (arr, cond) -> | ||
| 82 | [item for item in *arr when cond item] | ||
| 83 | |||
| 84 | reduce = (arr, init, action): init -> | ||
| 85 | init = action init, item for item in *arr | ||
| 86 | |||
| 77 | -- 管道操作符 | 87 | -- 管道操作符 |
| 78 | [1, 2, 3] | 88 | [1, 2, 3] |
| 79 | |> map (x) -> x * 2 | 89 | |> map (x) -> x * 2 |
