GenerativeComponents Help

Balance

Returns a new list comprised of all members of the list to which it is applied, but with every member 'wrapped' to the same nesting depth as the deepest-nested original member.

List.Balance()

How to Use it

a) Essentially, Balance turns a jagged list into a balanced list.

{a, {b, c, d}}.Balance() produces the list {{a}, {b, c,
d}}

while

{a, {{b, c}, d}}.Balance() produces the list {{{a}}, {{b,
c}, {d}}}

b) Balance takes an optional integer argument that lets you limit the depth to which its effect is applied. By default, that value is 'infinity' (int.MaxValue).

{a, {{b, c}, d}}.Balance(1) produces the list {a, {{b,
c}, d}}

(No change; the original list is already at rank 1.)

{a, {{b, c}, d}}.Balance(2) produces the list {{a}, {{b,
c}, d}}
{a, {{b, c}, d}}.Balance(3) produces the list {{{a}}, {{b,
c}, {d}}}

(The same as calling Balance with no argument at all.)