2

Say we have this nested vector:

(def coll [nil [["this" nil "this"] nil] nil "this"])

How would you design a remove-nil function so that all nil disappear?

(remove-nil coll)
;> [[["this" "this"]] "this"]
4

1 回答 1

5
(clojure.walk/postwalk #(if (coll? %) (into (empty %) (remove nil? %)) %) coll)
;=> [[["this" "this"]] "this"]
于 2013-09-13T17:53:26.067 回答