diff options
Diffstat (limited to 'src/clojure/contrib/lazy_seqs.clj')
-rw-r--r-- | src/clojure/contrib/lazy_seqs.clj | 42 |
1 files changed, 2 insertions, 40 deletions
diff --git a/src/clojure/contrib/lazy_seqs.clj b/src/clojure/contrib/lazy_seqs.clj index 9b40af26..1806cca2 100644 --- a/src/clojure/contrib/lazy_seqs.clj +++ b/src/clojure/contrib/lazy_seqs.clj @@ -21,17 +21,8 @@ ;; ;; == Lazy sequence functions == ;; -;; rotations - returns a lazy seq of all the rotations of a seq -;; -;; partition-all - like built-in partition, but does not throw away -;; the last partition if it is too short -;; -;; (permutations and combinations used to be here, but have -;; been moved to combinatorics.clj) -;; -;; random-permutation - from Jason Wolfe -;; -;; random-element - from Jason Wolfe +;; (rotations, partition-all, shuffle, rand-elt moved to seq_utils.clj) +;; (permutations and combinations moved to combinatorics.clj) ;; ;; [1] http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf ;; [2] http://clj-me.blogspot.com/2008/06/primes.html @@ -63,32 +54,3 @@ (defvar powers-of-2 (lazy-cons 1 (map #(bit-shift-left % 1) powers-of-2)) "A lazy sequence of all the powers of 2") - -(defn rotations - "Returns a lazy seq of all rotations of a seq" - [x] - (if (seq x) - (map - (fn [n _] - (lazy-cat (drop n x) (take n x))) - (iterate inc 0) x) - (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))))) - -(defn random-permutation - "Return a random permutation of coll" - [coll] - (let [l (java.util.ArrayList. coll)] - (java.util.Collections/shuffle l) - (seq l))) - -(defn random-element [s] - "Return a random element of this seq" - (nth s (rand-int (count s)))) |