【发布时间】:2016-05-18 16:01:09
【问题描述】:
我有以下结构
(def my-coll '{:data (
{:book/public-id #uuid "555b6f35-4e8c-42c5-bb80-b4d9147394c0", :book/name "AAA"}
{:book/public-id #uuid "555b6f35-4e8c-42c5-bb80-b4d9147394c1", :book/name "BBB"}
{:book/public-id #uuid "555b6f35-4e8c-42c5-bb80-b4d9147394c3", :book/name "CCC"}
)} )
我想只留下集合中带有 id 的输入,例如用于过滤
(def filter-coll '(#uuid "555b6f35-4e8c-42c5-bb80-b4d9147394c1" #uuid "555b6f35-4e8c-42c5-bb80-b4d9147394c2") )
我想得到
{:data (
{:book/public-id #uuid "555b6f35-4e8c-42c5-bb80-b4d9147394c0", :book/name "AAA"}
{:book/public-id #uuid "555b6f35-4e8c-42c5-bb80-b4d9147394c3", :book/name "CCC"}
)}
我使用 UUID 按单个值过滤这样的方式没有问题:
(prn {:data (filter #(= (:book/public-id %) #uuid "555b6f35-4e8c-42c5-bb80-b4d9147394c0") (my-coll :data))})
my-coll 是我的输入结构。 但是当我尝试按集合过滤时
(prn {:data (filter #(contains? (:book/public-id %) filter-coll) (my-coll :data))})
我有错误
contains? not supported on type: java.util.UUID
有什么方法可以通过集合 UUID 过滤输入结构?
【问题讨论】: