【发布时间】:2016-02-25 15:29:00
【问题描述】:
Clojure 中是否有一种简单的方法(可能使用 specter)根据具有已知名称的任意嵌套键是否包含元素来过滤集合?
例如。 :
(def coll [{:res [{:a [{:thekey [
"the value I am looking for"
...
]
}
]}
{:res ...}
{:res ...}
]}])
知道:a 可以有不同的名称,并且:thekey 可以嵌套在其他地方。
假设我想做:
#(find-nested :thekey #{"the value I am looking for"} coll) ;; returns a vector containing the first element in coll (and maybe others)
【问题讨论】:
-
集合必须是矢量和地图吗?还是允许其他类型?
-
你能澄清/提供一个你想要的返回值的样本吗?
-
@Elogent 我只有向量、原始值和映射(即没有集合。这些值来自 mongodb + congomongo 数据库)。
-
@jmargolisvt 会做