For sake of completeness/if this is useful for anyone else, a full implementation of the number-the-possible-split-locations method, including the original API with :min and :max options. Could probably be tidied up with transducers and such for all those filters but does the job.
(require '[clojure.math.combinatorics :as c]) (defn breaks->partition ([v brks] (breaks->partition 0 [] v brks)) ([start pars v brks] (if (empty? brks) (conj pars (subvec v start (count v))) (let [this-part (subvec v start (first brks))] (recur (first brks) (conj pars this-part) v (rest brks)))))) (defn min-parts [min splits] (>= (count splits) (- min 1))) (defn max-parts [max splits] (<= (count splits) (- max 1))) (defn ordered-partitions [v & {:keys [max min]}] (let [s (c/subsets (range 1 (count v))) fs (cond (and max min) (filter (partial max-parts max) (filter (partial min-parts min) s)) max (filter (partial max-parts max) s) min (filter (partial min-parts min) s) :else s)] (map (partial breaks->partition v) fs))) It does, alas, take more than 10 times as long as Mike's version. Which proves that one should never try to do anything faster than the core.matrix guy. :-) -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.