On 18 August 2010 04:44, Justin Kramer <jkkra...@gmail.com> wrote: > On Aug 17, 4:42 pm, Alan <a...@malloys.org> wrote: >> Devious! The OP wanted to handle underflow of the subs collection >> though, so you need a tweak: >> (apply assoc v (interleave (positions nil? v) >> (concat subs (repeat nil)))) > > interleave stops once either collection is exhausted. In your modified > version, nils replace nils when there are fewer substitutions than nil > positions, which is unnecessary. Unless I'm missing something...which > is entirely possible.
"nils replace nils when there are fewer substitutions than nil positions" was one of the requirements. >From the first post: > If nil is encountered in the first sequence and the second sequence is > exhaused, nil will be returned: > > e.g. user> (nil-coalesce (nil 1 2 3 nil nil) (4 5)) > (4 1 2 3 5 nil) -- Michael Wood <esiot...@gmail.com> -- 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