我在Clojure中有一个类似如下的地图:
(def stuff #{
{:a "help" :b "goodbye"}
{:c "help2" :b "goodbye"}
{:a "steve" :b "goodbye"}
{:c "hello2" :b "sue"}
}):我想提供一个搜索,以便:
(search stuff "help"):将返回:
#{
{:a "help" :b "goodbye"}
{:c "help2" :b "goodbye"}
}:最简单的方法是什么?
发布于 2011-04-12 00:06:01
user=> (defn search [s q] (select #(some (partial re-find (re-pattern q)) (vals %)) s))
#'user/search
user=> (search stuff "help")
#{{:a "help", :b "goodbye"} {:c "help2", :b "goodbye"}}这就是问题所在。
https://stackoverflow.com/questions/5623175
复制相似问题