其中是fmap(或如何对地图的每个值应用fn) [英] where is fmap (or how to apply a fn to every value of a map)
本文介绍了其中是fmap(或如何对地图的每个值应用fn)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想对地图的每个值应用一个函数。 fmap
工作。但是它移动到了什么命名空间?
I am trying to apply a function to every value of a map. fmap
does the job. But what namespace has it moved to?
我也写了下面的实现,但我认为这可能更好 -
I also have written the below implementation, but I think this could be better -
(defn map-over
[f m]
(->>
(map (fn [[k v]]
{k (f v)})
m)
(into {})))
推荐答案
迁移页面显示 clojure.contrib.generic
已迁移到 algo.generic
。
The migration page shows that clojure.contrib.generic
has been migrated to algo.generic
.
这篇关于其中是fmap(或如何对地图的每个值应用fn)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文