This solution, I think, does not do more map first than needed, avoids computing len and pieces more than once, uses nthnext to avoid extra cost of drop and computes the example
(first (second (split-at-subsequence [1 2] (range)))) (defn split-at-subsequence [mark input] (when-let [sequence (seq input)] (let [len (count mark) partition (partition-all len 1 sequence) step (fn step [pieces] (when pieces (let [[fst rst] (split-with #(not= mark %) pieces) tail (lazy-seq (step (nthnext rst len)))] (if (empty? fst) tail (list* (map first fst) tail)))))] (step partition)))) It works, but some little modifications of it which I think should work, do not. For instance, if we move the lazy-seq just before the let of the inner function, stops working. I need to work more on lazy sequences :-) Juan Manuel -- 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