wiki:Functions/Flatten

flatten

to flatten is to collapse a nested structure into a linear structure, to eliminate nesting by splicing elements of a nested substructure into a flatter one (one level flatter).

For classic Lists it is concat. For other data structures corresponding implementation should be provided.

The crucial idea is that an ordering is not implied. Nesting does not imply an ordering. Sets could be nested, but there is no notion of ordering. Only membership.

For sequential structures (a sequence implies an ordering) flattening preserves ordering.

The accompanying metaphor is removing a wooden fence one by one plank and placing them in a single row one after another.


Last modified 3 years ago Last modified on May 18, 2018, 8:14:19 AM
Note: See TracWiki for help on using the wiki.