Algosim documentation: flatten

flatten

Flattens a nested container.

Syntax

Description

If X is a list, possibly nested to any level, then flatten(X) returns the list of all non-container objects in X at any level.

Examples

compute(n! + δ, n, 1, 10, δ, −5, 5)
(−4, −3, −2, −1, 0, 1, 2, 3, 4, 5, 6)
(−3, −2, −1, 0, 1, 2, 3, 4, 5, 6, 7)
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
(19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29)
(115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125)
(715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725)
(5035, 5036, 5037, 5038, 5039, 5040, 5041, 5042, 5043, 5044, 5045)
(40315, 40316, 40317, 40318, 40319, 40320, 40321, 40322, 40323, 40324, 40325)
(362875, 362876, 362877, 362878, 362879, 362880, 362881, 362882, 362883, 362884, 362885)
(3628795, 3628796, 3628797, 3628798, 3628799, 3628800, 3628801, 3628802, 3628803, 3628804, 3628805)
flatten(ans)
−4
−3
−2
−1
0
1
2
3
4
5
6
−3
−2
−1
⋮

See also