flat

Prev Next

Function Names

flat

Description

In a parameter set, all elements which are also parameter sets (for example matrices), will be flattened by shifting all members upward. This function is not recursive, i.e. deeper parameter 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
parameter set
matrix
Matrix

Vector or matrix to flatten to parameter set

Return value

TypeDescription
parameter 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