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

byte-array

clojure.core

  • (byte-array size-or-seq)
  • (byte-array size init-val-or-seq)
Creates an array of bytes

1 Example top

  • ;; create an array of bytes
    ;; and demonstrate that you can use it in the standard Java fill function
    ;; note the needed byte coercion in the fill function call
    
    user=> (def bees (byte-array 10))
    #'user/bees
    
    user=> (for [i (range 10)](aset-byte bees i (* i i)))
    (0 1 4 9 16 25 36 49 64 81)
    
    user=> (vec bees)
    [0 1 4 9 16 25 36 49 64 81]
    
    user=> (java.util.Arrays/fill bees (byte 122))
    nil
    user=> (vec bees)
    [122 122 122 122 122 122 122 122 122 122]
    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:4152 top

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

Comments top

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