diff options
-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 |