partitionv

functionsince v1.11.121Edit
(partitionv n coll)
(partitionv n step coll)
(partitionv n step pad coll)

Source docstring:
Returns a lazy sequence of vectors 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 upto 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 partitionv
  ([n coll]
   (partitionv n n coll))
  ([n step coll]
   (lazy-seq
     (when-let [s (seq coll)]
       (let [p (into [] (take n) s)]
         (when (= n (count p))
           (cons p (partitionv n step (nthrest s step))))))))
  ([n step pad coll]
   (lazy-seq
     (when-let [s (seq coll)]
       (let [p (into [] (take n) s)]
         (if (= n (count p))
           (cons p (partitionv n step pad (nthrest s step)))
           (list (into [] (take n) (concat p pad)))))))))