1.3.0 permalink Arrow_down_16x16

int-array

clojure.core

  • (int-array size-or-seq)
  • (int-array size init-val-or-seq)
Creates an array of ints

1 Example top

  • ;; if you have a sequence, perhaps lazy, int-array will figure out the size
    user=> (aget (int-array [1 2 3]) 0)
    1
    user=> (int-array [1 2 3])
    #<int[] [i@263c8db9]>
    
    ;; if you need a certain size, with a constant initial value
    user=> (aget (int-array 5 1) 4)
    1
    user=> (alength (int-array 5))
    5
    
    ;; finally, you can specify a size + a sequence, which will initialize the array 
    ;; by taking size from the sequence
    user=> (alength (int-array 5 (range 10)))
    5
    ;; which is equivalent to
    user=> (alength (int-array (take 5 (range 10)))
    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:4649 top

(defn int-array
  "Creates an array of ints"
  {:inline (fn [& args] `(. clojure.lang.Numbers int_array ~@args))
   :inline-arities #{1 2}
   :added "1.0"}
  ([size-or-seq] (. clojure.lang.Numbers int_array size-or-seq))
  ([size init-val-or-seq] (. clojure.lang.Numbers int_array size init-val-or-seq)))
Vars in clojure.core/int-array:
Used in 0 other vars

Comments top

No comments for int-array. Log in to add a comment.