I have a solution : (defn unfold [f & as] (if-let [[hd new-as] (apply f as)] (lazy-seq (cons hd (apply unfold f new-as))) ()))
unfold could be called co-reduce or coreduce. It is the dual operation of reduce, in category theory. Instead of reducing a seq to create a value, it generates a seq from a value. (generate is sometimes a name for that, too) I don't know if it is somewhere in core or contrib. With this function, it is very simple: (defn nil-coalesce [s1 s2] (unfold #(and %1 (if (first %1) [(first %1) [(next %1) %2]] [(first %2) [(next %1) (next %2)]])) s1 s2)) -- 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