Friday, 13 September 2013

Clojure: What is the easiest way to remove all the nil items in a nested data structure?

Clojure: What is the easiest way to remove all the nil items in a nested
data structure?

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"]

No comments:

Post a Comment