Module ddash.algorithm.flatten

Flattens a range one level deep by removing non truthy values.

Example

auto arrayOfArrays = [[[1]], [[]], [[2], [3]], [[4]]];

// remove emptys
assert(arrayOfArrays.flatten.equal([[1], [], [2], [3], [4]]));
assert([[1], [], [2, 3], [4]].flatten.equal([1, 2, 3, 4]));

// remove empty all the way down
assert(arrayOfArrays.flattenDeep.equal([1, 2, 3, 4]));

import ddash.utils: Optional, some, no;
assert([some(some(3)), no!(Optional!int), some(some(2))].flattenDeep.equal([3, 2]));

Functions

NameDescription
flatten(range) Flattens a range one level deep by removing anything that's empty
flattenDeep(range) Flattens a range all the way down