Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Clojure 从嵌套映射获取值_Clojure - Fatal编程技术网

Clojure 从嵌套映射获取值

Clojure 从嵌套映射获取值,clojure,Clojure,我有一个嵌套映射,如何获取所有:kvota关键字的值?结果应该是-5.8,3.2,2.25。我尝试使用选择键,但没有任何运气 {:b4f0d011-31a2-4be3-bb8d-037725310207 {:tiket {:3 {:id 13, :par Porto - Zenit, :igra 2, :kvota 5.8}, :2 {:id 12, :par Celtic - Ajax, :igra x, :kvota 3.2}, :1 {:id 11, :par Arsenal - Dort

我有一个嵌套映射,如何获取所有:kvota关键字的值?结果应该是-5.8,3.2,2.25。我尝试使用选择键,但没有任何运气

{:b4f0d011-31a2-4be3-bb8d-037725310207 {:tiket {:3 {:id 13, :par Porto - Zenit, :igra 2, :kvota 5.8}, :2 {:id 12, :par Celtic - Ajax, :igra x, :kvota 3.2}, :1 {:id 11, :par Arsenal - Dortmund, :igra 1, :kvota 2.25}}}}

这将获得与数据结构中任意位置的每个
:kvota
对应的值

;; Data in quesiton doesn't read as-is, so this is altered slightly.
(def data
  {:b4f0d011-31a2-4be3-bb8d-037725310207
   {:tiket
    {:1 {:kvota 2.25, :par "Arsenal - Dortmund", :igra 1, :id 11}
     :3 {:kvota 5.8, :par "Porto - Zenit", :igra 2, :id 13}
     :2 {:kvota 3.2, :par "Celtic - Ajax", :igra "x", :id 12}}}})

(keep :kvota (tree-seq map? vals data)) ; (2.25 5.8 3.2)

回答得很好!我从来没有想过用那种方式使用
tree-seq
。顺便说一下,
(删除零?(映射f…)
(保留f…
@OmriBernstein
保留
)相同-好主意。我已经改变了。谢谢正是我需要的。