Oh, and, duh.  Both lists are traversed at each iteration as Nicolas
stated.

On Aug 17, 3:56 pm, Rising_Phorce <josh.fe...@gmail.com> wrote:
> I posted because clojure *tends* to be so succinct and in this case
> the solution complexity seems disproportionate to the problem.  In my
> first post I forgot to mention my second attempt...
>
> (map #(if (nil? %1) %2 %1) [nil 1 2 3 nil nil] [4 5])
>
> but it got ugly because I needed to extend the replacements to the the
> same length as the maybe-nil collection...
>
> (defn nil-coalesce2 [maybe-nil replacements]
>   (let [cnt-mn (count maybe-nil)
>         cnt-r (count replacements)]
>     (if (= cnt-mn cnt-r)
>       (map #(if (nil? %1) %2 %1) maybe-nil replacements)
>     (map #(if (nil? %1) %2 %1) maybe-nil (concat replacements (repeat
> (- cnt-mn cnt-r) nil))))))

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to