add, sub, mul, div, and, or, xor, xnor
The following functions calculate the parameters from left to right in the same way as if the corresponding operator is used. All variable types as supported by the operators are supported in this function, too. For example, sub(10,2,3) is the same as 10-2-3, both returning 5.
Function Name | Related operator | Function Name | Related operator |
---|---|---|---|
add | + | and | & |
sub | - | or | | |
mul | * | xor | != |
div | / | xnor | == |
As long the corresponding operators allow mixed types (e.g. using numerals to add days to a date, or adding boolans to numerals where booleans
are implicitly converter to 0 or 1), then they are also supported by this function. These functions are very useful for processing large series
and series of different sizes efficiently.
Two parameter passing methods for series functions
The functions described on this page as well as a large number additional series and statistics functions (e.g. min(), max 123()', etc.) support the following two different methods to pass parameters
into the functions:
Direct Parameter Passing | Put all parameters to be calculated into the this function and they will be processed from left to right |
Advanced Indirect Parameter Passing | Put all parameters to be caluclated into a set and provide them into the 1st function parameter. 2 additional function parameters are available to limit the range of elements to be processed. |
Min 1
No. | Type | Description |
---|---|---|
1, etc. input |
valid types | Value All values to be applied in the calculations |
Alt. 1 input |
set | Value All values to be calculated from left to right are in the parameters set |
Alt. 2 input |
numeral | Starting set element to include Points to the starting set element. Negative indexing is allowed here, i.e. -1 refers to last element in the set. Default value: 0 |
Alt. 3 input |
numeral | Ending set element to include Points to the ending set element. Negative indexing is allowed here, i.e. -1 refers to last element in the set. Default value: Last value |
Type | Description |
---|---|
valid types | Result Calculated value |
echo( add( 1, 2, 3 ) ); // 6
echo( add( {1,2,3} ) ); // 6
echo( add( {1,2,3}, 1) ); // 5
echo( add( date('2013-12-31'), 1, 2 ) ); // 03. Jan 2014
echo( add( Hello, ' ', World) ); // Hello World
echo( sub( 10, 2,3 ) ); // 5
echo( div( 1000, 2, 50) ); // 10
echo( xor( true, false, true ) ); // false
6
6
5
2014-01-03
Hello World
5
10
false