从集合中删除字符串实例

Mic*_*inh 2 clojure

我有这个系列

("string" {:1 a} "string" {:2 b} "string")
Run Code Online (Sandbox Code Playgroud)

我想只返回地图元素.

如此,

({:1 a} {:2 b})
Run Code Online (Sandbox Code Playgroud)

nta*_*lbs 8

如果您打算删除列表中的字符串,则使用removesting?谓词.这非常简单.

user=> (remove string? '("string" {:1 a} "string" {:2 b} "string"))
({:1 a} {:2 b})
Run Code Online (Sandbox Code Playgroud)

如果你打算删除map以外的元素,那么你最好使用filtermap?谓词,就像@Reut的回答一样.


Reu*_*ani 6

使用过滤器可能?

(filter map? coll)
Run Code Online (Sandbox Code Playgroud)

输出:

({:1 3} {:2 4})
Run Code Online (Sandbox Code Playgroud)