Difference between revisions of "Array.$$()"

From ZCubes Wiki
Jump to navigation Jump to search
Line 50: Line 50:
 
|  
 
|  
 
{| class="wikitable"|-
 
{| class="wikitable"|-
| 3  
+
| 3 || 1 || 2  
|-
 
| 1  
 
|-
 
| 2  
 
 
|}
 
|}
 
   
 
   
Line 60: Line 56:
 
|  
 
|  
 
{| class="wikitable"|-
 
{| class="wikitable"|-
| 7  
+
| 7 || 5 || 2  
|-
 
| 5  
 
|-
 
| 2  
 
 
|}
 
|}
 
   
 
   
Line 70: Line 62:
 
|  
 
|  
 
{| class="wikitable"|-
 
{| class="wikitable"|-
| 1  
+
| 1 || 9 || -8  
|-
 
| 9  
 
|-
 
| -8  
 
 
|}
 
|}
 
   
 
   
Line 80: Line 68:
 
|  
 
|  
 
{| class="wikitable"|-
 
{| class="wikitable"|-
| 5  
+
| 5 || 3 || 2  
|-
 
| 3  
 
|-
 
| 2  
 
 
|}
 
|}
 
   
 
   
 
|}
 
|}

Revision as of 15:44, 30 December 2016

Array.$$(Function|Array of Functions[,param1,param2,...])

This returns the result of each row of the Array being operated on by the function or array of functions passed. The parameters provided following the function/function array is passed to the function with each row as the first parameter. Used for aggregate functions or functions that apply on each row (such as a spreadsheet calculation).

For example, a=|4,4,1..10|

1 2 3 4
5 6 7 8
9 10 1 2
3 4 5 6

a.$$(SUM)

10
26
22
18

gives row wise sums of each row.


Functions can be defined as a string with a variable, say, x. The following shows a calculation done in each row by subracting second from the first element in each row.

a.$$("x[2]-x[0]")

2
2
-8
2


a.$$("[x[2],x[0],x[2]-x[0]]")

3 1 2
7 5 2
1 9 -8
5 3 2