flat

Prev Next

Function Names

flat

Description

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.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1

Parameters

No.TypeDescription
1
input
set
matrix
Matrix

Vector or matrix to flatten to set

Return value

TypeDescription
set Flattened vector

Examples

               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(

Output

{1,2,3}
{1,2,3}
{1,2,3}
{{1,2},3}
Try it yourself: Open LIB_Function_flat.b4p in B4P_Examples.zip. Decompress before use.

See also

vertical
horizontal
diagonal