Here's a pass using reduce, keeping both collections in the return value,
conj-ing to one and taking from the other as necessary...
(defn nil-coalesce [coll subs]
(first (reduce (fn [[a b] x]
(if x
[(conj a x) b]
[(conj a (first b)) (rest b)]))
[[] subs] coll)))
user> (nil-coalesce [nil 1 2 3 nil nil] [4 5])
[4 1 2 3 5 nil]
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en