← index

Array

inherits Object

A typed, contiguous numeric column: every element is the same dtype (#float64 or #int64), held in one packed buffer rather than exploded into per-element values. The layout is Apache Arrow's non-nullable primitive format, so extensions (numpy, databases) read the same bytes with zero conversion.

Build with Array.ofInts: / Array.ofFloats:; leave the bulk world with toList. An untyped blob of octets belongs in Bytes instead.

Class methods

ofFloats:

A float64 Array packed from a list of numbers (integers are widened); a non-number raises a TypeError naming the element.

Array.ofFloats:#(1.5 2.5)     "* -> Array[float64; 2]

native

ofInts:

An int64 Array packed from a list of integers; a non-integer raises a TypeError naming the element.

Array.ofInts:#(1 2 3)     "* -> Array[int64; 3]

native

Instance methods

at:

The element at a zero-based index — a Double or an Integer to match the dtype; out of range raises a catchable IndexError.

(Array.ofFloats:#(1.5 2.5)).at:1     "* -> 2.5

native

dtype

The element type as a Symbol: #float64 or #int64.

(Array.ofInts:#(1 2 3)).dtype     "* -> int64

native

length

The number of elements.

(Array.ofInts:#(1 2 3)).length     "* -> 3

native

s

The display string: dtype and element count, not the elements.

(Array.ofInts:#(1 2 3)).s     "* -> Array[int64; 3]

native

scale:

A new Array of the same dtype with every element multiplied by a factor — any number for a float64 array, an integer (wrapping on overflow) for an int64 one.

((Array.ofInts:#(1 2 3)).scale:10).toList     "* -> #(10 20 30)

native

sum

The sum of all elements, reduced over the packed buffer in one pass: a Double from a float64 array, an Integer from an int64 one.

(Array.ofInts:#(1 2 3)).sum     "* -> 6
(Array.ofFloats:#(1.5 2.25)).sum     "* -> 3.75

native

toList

The elements exploded into an ordinary List — leaving the packed, bulk world, so reach for it at the edges rather than per element.

(Array.ofInts:#(1 2 3)).toList     "* -> #(1 2 3)

native