diff options
author | scgilardi <scgilardi@gmail.com> | 2009-02-12 02:53:40 +0000 |
---|---|---|
committer | scgilardi <scgilardi@gmail.com> | 2009-02-12 02:53:40 +0000 |
commit | 86b4f045e98ecc0b16fe5bd59dd219a35e594170 (patch) | |
tree | a649f47e25849e1444cd47cbc9a63c68759780d8 | |
parent | f6ec940c64c350ea2c201c9eaa53bce8ccd95eb8 (diff) |
fix issue 28, more capable partition-all, from H.Duerer
-rw-r--r-- | src/clojure/contrib/lazy_seqs.clj | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/clojure/contrib/lazy_seqs.clj b/src/clojure/contrib/lazy_seqs.clj index 9b40af26..e9915143 100644 --- a/src/clojure/contrib/lazy_seqs.clj +++ b/src/clojure/contrib/lazy_seqs.clj @@ -75,12 +75,14 @@ (list nil))) (defn partition-all - "Lazily break s into chunks of length n (or less, for the - final chunk)." - [n s] - (when (seq s) - (lazy-cons (take n s) - (partition-all n (drop n s))))) + "Lazily break coll into chunks of length n (or less, for the final + chunk)." + ([n coll] + (partition-all n n coll)) + ([n step coll] + (when (seq coll) + (lazy-cons (take n coll) + (partition-all n step (drop step coll)))))) (defn random-permutation "Return a random permutation of coll" |