![](/img/trans.png)
[英]How to retrive in Clojure from a vector of maps (Elasticseach buckets) the doc_count of a given key
[英]how to remove a given key from a series of maps in a vector in clojure?
在 clojure 中,给定一个数据结构[{:a "foo" :b "bar"} {:a "biz" :b "baz"}]
我怎么会得到[{:b "bar"}{:b "baz"}]
最简洁?
dissoc
的回答:a
如果您希望所有地图都没有:a
。
如果您只需要一个:b
键的地图列表,您可以这样做
<!-- language-all: lang-clj -->
;; Assuming my-map is the object map
;; map returns a lazy sequence
(map #(hash-map :b (:b %)) my-map)
;; or
(map #(select-keys % [:b]) mp)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.