0

我有一套(我认为)物品;与此类似:

(def a ({:answers 3 :comments 12} {} {} {:answers 43 :comments 23} {}))

理想情况下,我想删除该列表中的所有空项目,但保持集合完整,否则..我想做的是:

(defn drop-empty-items
 [a]
 (take-when #(not empty? %) a))

但这显然根本不起作用..

请问我该怎么做?

我正在尝试返回以下效果:

({:answers 3 :comments 12} {:answers 43 :comments 23})

drop-empty-items

4

1 回答 1

2
(def a '({:answers 3 :comments 12} {} {} {:answers 43 :comments 23} {}))

(remove empty? a) 
;=> ({:answers 3, :comments 12} {:answers 43, :comments 23})
于 2013-07-23T13:20:18.017 回答