Deep Unary Operators

Prev Next

Introduction

All valid unary operators can be applied as deep operators in order to address the parameter set elements directly. The number of accent circumflex symbols behind the operator determines the depth to use.

  echo("Deep unary operators on simple parameter sets (vectors):");

  a[] = { 1,2,3,4,5 };
  b[] = { hu, ha, he, ho, hi };


  echo( -a[] );      // Descending sorting order
  echo( -^a[] );     // Negating elements
  echo;

  echo( + b[] );     // Ascending sorting order
  echo( +^b[] );     // Upper case on elements
  echo( !^b[] );     // Capitalizing elements
  echo;

  echo("Deep unary operators on nested parameter sets (matrices):");

  a[] = { { 5, 15, 10 }, { 16, 6, 26 }, { 37, 17, 7 } };  

  echo( - a [] );    // Descending sorting of all elements
  echo( -^a [] );    // Desending sorting of each marix row
  echo( -^^a[] );    // Negating the elements
Deep unary operators on simple parameter sets (vectors):
{5,4,3,2,1}
{-1,-2,-3,-4,-5}

{'ha','he','hi','ho','hu'}
{'HU','HA','HE','HO','HI'}
{'Hu','Ha','He','Ho','Hi'}

Deep unary operators on nested parameter sets (matrices):
{{37,17,7},{26,16,6},{15,10,5}}
{{15,10,5},{26,16,6},{37,17,7}}
{{-5,-15,-10},{-16,-6,-26},{-37,-17,-7}}
Try it yourself: Open LAN_Features_deep_unary_operators.b4p in B4P_Examples.zip. Decompress before use.