Yeah! Golf!
user=> (defn nil-coalesce
[coll replacements]
(lazy-seq
(when-let [s (seq coll)]
(let [fst (first s)]
(if (nil? fst)
(cons (first replacements)
(nil-coalesce (rest s) (rest replacements)))
(cons fst (nil-coalesce (rest s) replacements)))))))
#'user/nil-coalesce
user=> (nil-coalesce [nil 1 2 3 nil nil] [4 5])
(4 1 2 3 5 nil)
Sincerely
Meikel
--
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