Array flattening

Uses
- One-dimensional arrays
- Integers

Any array can be flattened into a one-dimensional array containing all its elements:
flatten(Array) : Array1D(ℕ)

The order of the elements in the flattened version is the one obtained by iterating over the last index in the innermost loop.

For one-dimensional arrays, flattening changes nothing:
s_:𝕊, flatten(a:Array1D(s_)) ⇒ a

For literal array terms, flattening is performed in Pharo:
A:Array, flatten(A) ⇒ Pharo:"A ensureArrayTerm. A flattenedAsArrayTerm"

Examples

flatten({[]}) ⇒ {[]}
flatten({[1, 2, 3]}) ⇒ {[1, 2, 3]}
2D flatten({[[1, 2], [3, 4]]}) ⇒ {[1, 2, 3, 4]} (uses 2D Two-dimensional arrays)