You're viewing version 1.2.0 of short-array. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

short-array

clojure.core

  • (short-array size-or-seq)
  • (short-array size init-val-or-seq)
Creates an array of shorts

1 Example top

  • ;; create an array of shorts using short-array
    ;; and demonstrate how it can be used with the java Arrays functions
    ;; (note the needed coercions)
    
    user=> (def ss (short-array (map short (range 3 10))))
    #'user/ss
    user=> (type ss)
    [S
    user=> (vec ss)
    [3 4 5 6 7 8 9]
    user=> (java.util.Arrays/binarySearch ss (short 6))
    3
    user=> (java.util.Arrays/fill ss (short 99))
    nil
    user=> (vec ss)
    [99 99 99 99 99 99 99]
    user=>
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:4168 top

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

Comments top

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