【发布时间】:2015-12-01 10:36:23
【问题描述】:
我在 Clojure 中有这样的变量测试:
( def test '([:circle {:cx 428, :cy 245, :r 32.2490309931942, :fill red}] [circle] [:line {:x1 461, :y1 222, :x2 365, :y2 163}] [:line {:x1 407, :y1 102, :x2 377, :y2 211}] [line]))
我想从中删除 [line] 和 [circle] 对象,让它看起来像这样:
([:circle {:cx 428, :cy 245, :r 32.2490309931942, :fill red}] [:line {:x1 461, :y1 222, :x2 365, :y2 163}] [:line {:x1 407, :y1 102, :x2 377, :y2 211}] )
在 Clojure 中是否有一种简单的方法可以做到这一点?
我看过这个帖子How can I remove an item from a sequence in Clojure?
和 remove() 但我仍然没有它。该线程显示:
(remove #{:foo} #{:foo :bar}) ; => (:bar)
(remove #{:foo} [:foo :bar]) ; => (:bar)
(remove #{:foo} (list :foo :bar)) ; => (:bar)
但对我来说,我有更多类似的东西:
(remove #????? ([:foo :bar] [foo] [bar]))
我只想以 ([:foo :bar]) 结束。
【问题讨论】: