1.3.0 permalink Arrow_down_16x16

subvec

clojure.core

  • (subvec v start)
  • (subvec v start end)
Returns a persistent vector of the items in vector from
start (inclusive) to end (exclusive). If end is not supplied,
defaults to (count vector). This operation is O(1) and very fast, as
the resulting vector shares structure with the original and no
trimming is done.

1 Example top

  • ;; not supplying 'end' returns vector from 'start' to (count vector)
    user=> (subvec [12 3 4 5 6 7] 2)
    [4 5 6 7]
    
    ;; supplying 'end' returns vector from 'start' to element (- end 1)
    user=> (subvec [12 3 4 5 6 7] 2 4)
    [4 5]
    
    
    
    
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:3361 top

(defn subvec
  "Returns a persistent vector of the items in vector from
  start (inclusive) to end (exclusive).  If end is not supplied,
  defaults to (count vector). This operation is O(1) and very fast, as
  the resulting vector shares structure with the original and no
  trimming is done."
  {:added "1.0"
   :static true}
  ([v start]
   (subvec v start (count v)))
  ([v start end]
   (. clojure.lang.RT (subvec v start end))))
Vars in clojure.core/subvec:
Used in 0 other vars

Comments top

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