Array size

Uses
- One-dimensional arrays
- Integers

Shape

The shape of an array can be obtained as
shape(Array) : Array1D(ℕ)
For literal array terms, it is computed in Pharo:
A:Array, shape(A) ⇒ Pharo:"A ensureArrayTerm. A shapeAsArrayTerm"

Length

The length of an array is the number of indices along its first dimension. It can be obtained as
length(Array) :
It is zero for empty arrays:
length(A:EmptyArray(0)) ⇒ 0
For literal array terms, it is computed in Pharo:
length(A:Array) ⇒ Pharo:"A ensureArrayTerm. A lengthAsTerm"

Examples

One-dimensional arrays:
shape({[]}) ⇒ {[0]}
length({[]}) ⇒ 0
shape({[1, 4, 9]}) ⇒ {[3]}
length({[1, 4, 9]}) ⇒ 3

example Two-dimensional arrays:
example shape({[[], []]}) ⇒ {[2, 0]}
example shape({[[1, 4, 9], [16, 25, 36]]}) ⇒ {[2, 3]}
example length({[[1, 4, 9], [16, 25, 36]]}) ⇒ 2