过滤映射条目中多个键的值和 return 具有这些条目的映射 Clojure

Filter on the values of multiple keys in a map entry and return a map with those entries Clojure

我是 clojure 的新手,需要一些帮助。

在 clojurescript 中,我使用映射(存储在 atom 中)构建了一个 html table,例如

[{:id 2, :category "Big bang theory", :name "The Big Bang!"} 
{:id 3, :category "The big Lebowski", :name "Ethan Coen"}
{:id 4, :category "Chitty Chitty Bang Bang", :name "Roald Dahl"}]

我想创建一个搜索词(即 "ban")en return 一个地图,其中包含在其中一个键中包含该词(或其一部分)的那些条目值。

在 "ban" 的情况下应该 return

[{:id 2, :category "Big bang theory", :name "The Big Bang!"} 
{:id 4, :category "Chitty Chitty Bang Bang", :name "Roald Dahl"}]

根据上面的地图,table 只更新了这两个条目。

我发现了一些有趣的解决方案,但它们都专注于一个键(即 :category 或 :name),而不是地图条目中的所有键。

我认为 试图达到同样的目的,但我认为没有人给出答案。感谢您的帮助 :D

(def maps
  [{:id 2, :category "Big bang theory", :name "The Big Bang!"}
   {:id 3, :category "The big Lebowski", :name "Ethan Coen"}
   {:id 4, :category "Chitty Chitty Bang Bang", :name "Roald Dahl"}])

(filter
 #(some
   (fn [v]
     (when (string? v)
       (-> v
           (str/lower-case)
           (str/includes? "ban"))))
   (vals %))
 maps)