You're viewing version 1.2.0 of subvec. The latest stable version of Clojure Core is 1.3.0.
1.2.0 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:2899 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"}
  ([v start]
   (subvec v start (count v)))
  ([v start end]
   (. clojure.lang.RT (subvec v start end))))
Vars in clojure.core/subvec: count defn
Used in 1 other vars with-open

Comments top

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