1.2.0 permalink Arrow_down_16x16
  • (rotations x)
Returns a lazy seq of all rotations of a seq

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/seq.clj:129 top

(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)))
Vars in clojure.contrib.seq/rotations: defn drop fn inc iterate lazy-cat list map seq take
Used in 0 other vars

Comments top

No comments for rotations. Log in to add a comment.