From a8926771f1ae025d7bb7d39a33effa92b49393cc Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 22 May 2025 09:07:37 +0800 Subject: Updated docs. [skip CI] --- doc/docs/doc/README.md | 10 ++++++++++ doc/docs/zh/doc/README.md | 10 ++++++++++ 2 files changed, 20 insertions(+) (limited to 'doc/docs') 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 = * name: "bread" count: 3 +-- list comprehension +map = (arr, action) -> + [action item for item in *arr] + +filter = (arr, cond) -> + [item for item in *arr when cond item] + +reduce = (arr, init, action): init -> + init = action init, item for item in *arr + -- pipe operator [1, 2, 3] |> 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 = * name: "bread" count: 3 +-- 列表推导 +map = (arr, action) -> + [action item for item in *arr] + +filter = (arr, cond) -> + [item for item in *arr when cond item] + +reduce = (arr, init, action): init -> + init = action init, item for item in *arr + -- 管道操作符 [1, 2, 3] |> map (x) -> x * 2 -- cgit v1.2.3-55-g6feb