JanetDocsI'm feeling luckyGitHub sign in

tarray/new



    cfunction

    (tarray/new type size &opt stride offset tarray|buffer)

    Create new typed array.


1 exampleSign in to add an example
Loading...
(def u8s (tarray/new :uint8 10))
(def i8s (tarray/new :int8 10))
(def u16s (tarray/new :uint16 10))
(def i16s (tarray/new :int16 10))
(def u32s (tarray/new :uint32 10))
(def i32s (tarray/new :int32 10))
(def u64s (tarray/new :uint64 10))
(def i64s (tarray/new :int64 10))
(def f32s (tarray/new :float32 10))
(def f64s (tarray/new :float64 10))

(def f64s-every-other (tarray/new :float64 5 2 0 (tarray/buffer f64s))) # size 5, stride 2, offset 0

(eachk x f64s (put f64s x x))
(eachp x f64s-every-other (pp x))
#->
# (0 0)
# (1 2)
# (2 4)
# (3 6)
# (4 8)
Nananas