【发布时间】:2022-01-04 15:53:23
【问题描述】:
(def coll [10 27 7 12])
想要的结果是:
==> (10 37 44 56)
我试过了:
(map #(+ % (next %)) coll)
没有成功
【问题讨论】:
标签: clojure
(def coll [10 27 7 12])
想要的结果是:
==> (10 37 44 56)
我试过了:
(map #(+ % (next %)) coll)
没有成功
【问题讨论】:
标签: clojure
reductions 可以做到:
(reductions + [10 27 7 12])
; → (10 37 44 56)
【讨论】:
reduce 函数之外找到了 reductions 的用例。 ;-)