On 18 August 2010 04:44, Justin Kramer <[email protected]> wrote: > On Aug 17, 4:42 pm, Alan <[email protected]> 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 <[email protected]> -- 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
