partition

functionsince v0.0-927 clojure.core/partitionEdit
(partition n coll)
(partition n step coll)
(partition n step pad coll)

Details:

Returns a lazy sequence of lists of n items each, at offsets step apart.

If step is not supplied, defaults to n, i.e. the partitions do not overlap.

If a pad collection is supplied, its elements will be used as necessary to complete the last partition up to n items.

Returns a partition with less than n items if there are not enough padding elements.


See Also:


Source docstring:
Returns a lazy sequence of lists of n items each, at offsets step
apart. If step is not supplied, defaults to n, i.e. the partitions
do not overlap. If a pad collection is supplied, use its elements as
necessary to complete last partition up to n items. In case there are
not enough padding elements, return a partition with less than n items.
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn partition
  ([n coll]
     (partition n n coll))
  ([n step coll]
     (lazy-seq
       (when-let [s (seq coll)]
         (let [p (take n s)]
           (when (== n (count p))
             (cons p (partition n step (drop step s))))))))
  ([n step pad coll]
     (lazy-seq
       (when-let [s (seq coll)]
         (let [p (take n s)]
           (if (== n (count p))
             (cons p (partition n step pad (drop step s)))
             (list (take n (concat p pad)))))))))