mixed :sub ( mixed &ARG , … )
mixed :- ( mixed &ARG , … )
Takes any number of arguments. Performs subtraction between the rightmost pair of elements, then the second-rightmost, et cetera. Subtracts the value of the right element from the left one. Note that references will modify the values of variables.
Returns a copy of the value the leftmost argument ended up with.
The table below contains rules for subtracting values. Note that these rules are non-symmetrical; swapping the values may yield a different result. The row contains the type of the first (left) value in pair, while the column contains the type of the second (right) value in pair.
NIL | bool | bin | oct | int | hex | float | string | array | dict | |
---|---|---|---|---|---|---|---|---|---|---|
NIL | Arithmetics on NIL values have no effect. | |||||||||
bool | No effect. | Equal to a logical XOR. | If number is non-zero, it's treated as TRUE. Bool subtraction is then performed. | Float is treated as TRUE if absolute value of number is greater-or-equal to 1.0. Bool subtraction is then performed. | String is treated as TRUE if it equals true or contains a non-zero number. Bool subtraction is then performed. | Structure is treated as TRUE if it's non-empty. | ||||
bin | No effect. | Number is decreased by 1 if bool is TRUE. | No type juggling needed. | Subtraction is performed, the result truncated and then put into integer. | String is converted to number (with regard to base). | Subtracts the number of entries in structure. | ||||
oct | ||||||||||
int | ||||||||||
hex | ||||||||||
float | No effect. | Number is decreased by 1 if bool is TRUE. | Integer part is decreased, fraction part remains unchanged. | No type juggling needed. | String is converted to float. | Float is decreased by number of entries in structure. | ||||
string | No effect. | |||||||||
array | Subtraction is performed on each structure element separately. | Subtraction is performed between keys present in both structures. | ||||||||
dict |
# :sub example. :set &NUM i20 :writeln $NUM :sub &NUM i40 s'20' # s'20' is subtracted from i40, and then the result is subtracted from &NUM. :writeln $NUM # Should print 0.
wikipage modified on 2014/0601/2317