Clojure: summing values in a collection of maps

自闭症网瘾萝莉.ら 提交于 2019-12-01 19:07:00

If you really want to sum the values of the common keys you can do the whole transformation in one step:

(apply merge-with + data)
=> {:a 2, :b 4, :c 6}

To sum the sub sequences you have:

(apply map + '((1 2) (1 2)))
=> (2 4)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!