首页 > 解决方案 > 使幽灵返回(部分)所选路径

问题描述

在以下结构中,我知道如何遍历:x的所有子项的值:whatever

=> (specter/select
       [:whatever specter/MAP-VALS :x]
       {:whatever {:a {:x 1} :b {:x 2}}})
[1 2]

我想得到的是类似于以下内容的内容,其中包含通配符映射键。

[[:a 1] [:b 2]]

幽灵怎么能做到这一点?

标签: clojurespecter

解决方案


(select
        [:whatever ALL (collect-one FIRST) LAST :x]
        {:whatever {:a {:x 1}
                    :b {:x 2}
                    :c {:x 55}}})
=> [[:a 1] [:b 2] [:c 55]]

推荐阅读