File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,6 +74,16 @@ inventory =
7474 * name: "bread"
7575 count: 3
7676
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+
7787-- pipe operator
7888[1, 2, 3]
7989 |> map (x) -> x * 2
Original file line number Diff line number Diff line change @@ -74,6 +74,16 @@ inventory =
7474 * name: "bread"
7575 count: 3
7676
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+
7787-- 管道操作符
7888[1, 2, 3]
7989 |> map (x) -> x * 2
You can’t perform that action at this time.
0 commit comments