flat
In a set, all elements which are also sets (for example matrices), will be flattened by shifting all members upward.
This function is not recursive, i.e. deeper sets beyond 2nd level remain unaffected.
The matrices may contain contents of all data types and not just numerals.
Indirect parameter passing is disabled
1
No. | Type | Description |
---|---|---|
1 input |
set matrix |
Matrix Vector or matrix to flatten to set |
Type | Description |
---|---|
set | Flattened vector |
echo( flat( {1,2,3} ) ); // Returns {1,2,3}
echo( flat( {{1,2,3}} ) ); // Same
echo( flat( {{1},{2},{3}} ) ); // Same
echo( flat( {{{1,2}}, {3}} ) ); // Returns {{1,2},3} (Only 2-level flattening(
{1,2,3}
{1,2,3}
{1,2,3}
{{1,2},3}