load help; @[name] dao.operator @[name] @[title] Operators @[title] @[text] Dao Language supports a rich set of operators to facilitate the writing of more expressive scripts. Many of these operators can be used for different data types. Please note, in the following operators that involve one or more arrays, those operators are done in element-wise. @[text] @[name] dao.operator.arithmetic @[name] @[title] Arithmetic Operators @[title] @[text] @[code] # Binary operators: (int|float|complex|array) + (int|float|complex|array) # Addtion; (int|float|complex|array) - (int|float|complex|array) # Subtraction; (int|float|complex|array) * (int|float|complex|array) # Multiplication; (int|float|complex|array) / (int|float|complex|array) # Division; (int|float|array) % (int|float|array) # Modulo; (int|float|array) ** (int|float|array) # Power; #Unary operators: + (int|float|complex|array) # Unary plus; - (int|float|complex|array) # Unary minus; ++ (int|float|complex|array) # Prefix Increment; -- (int|float|complex|array) # Prefix Decrement; @[code] @[text] @[name] dao.operator.comparison @[name] @[title] Comparison Operators @[title] @[text] @[code] (bool|int|float) == (bool|int|float) # Equal to; (bool|int|float) != (bool|int|float) # Not equal to; (bool|int|float) < (bool|int|float) # Less than; (bool|int|float) > (bool|int|float) # Greater than; (bool|int|float) <= (bool|int|float) # No greater than; (bool|int|float) >= (bool|int|float) # No less than; complex == complex # Equal to; complex != complex # Not equal to; array == array # Equal to; array != array # Not equal to; array(||) < array(||) # Less than; array(||) > array(||) # Greater than; array(||) <= array(||) # No greater than; array(||) >= array(||) # No less than; string == string # Equal to; string != string # Not equal to; string < string # Less than; string > string # Greater than; string <= string # No greater than; string >= string # No less than; @[code] @[text] @[name] dao.operator.logic @[name] @[title] Logic Operators @[title] @[text] @[code] ! (bool|int|float) # Logic negation (NOT); not (bool|int|float) # Logic negation (NOT); (bool|int|float) && (bool|int|float) # Logic AND; (bool|int|float) and (bool|int|float) # Logic AND; (bool|int|float) || (bool|int|float) # Logic OR; (bool|int|float) or (bool|int|float) # Logic OR; @[code] @[text] @[name] dao.operator.bitwise @[name] @[title] Bitwise Operators @[title] @[text] @[code] ~ (int|float) # Bitwise NOT; (int|float) & (int|float) # Bitwise AND; (int|float) | (int|float) # Bitwise OR; (int|float) ^ (int|float) # Bitwise XOR; (int|float) << (int|float) # Bitwise left shift; (int|float) >> (int|float) # Bitwise right shift; @[code] Please note, non-integer operands are converted to integers. @[text] @[name] dao.operator.assignment @[name] @[title] Assignment Operators @[title] @[text] @[subsection]Compound Assignment Operators@[subsection] @[code] (int|float) += (int|float) # Addition assignment; (int|float) -= (int|float) # Subtraction assignment; (int|float) *= (int|float) # Multiplication assignment; (int|float) /= (int|float) # Division assignment; (int|float) %= (int|float) # Modulo assignment (int|float) &= (int|float) # Bitwise AND assignment; (int|float) |= (int|float) # Bitwise OR assignment; (int|float) ^= (int|float) # Bitwise XOR assignment; array(|) += (int|float) # Addition assignment; array(|) -= (int|float) # Subtraction assignment; array(|) *= (int|float) # Multiplication assignment; array(|) /= (int|float) # Division assignment; array(|) %= (int|float) # Modulo assignment array(|) += array(|) # Addition assignment; array(|) -= array(|) # Subtraction assignment; array(|) *= array(|) # Multiplication assignment; array(|) /= array(|) # Division assignment; array(|) %= array(|) # Modulo assignment array += (int|float|complex|array) # Addition assignment; array -= (int|float|complex|array) # Subtraction assignment; array *= (int|float|complex|array) # Multiplication assignment; array /= (int|float|complex|array) # Division assignment; array %= (int|float|complex|array) # Modulo assignment @[code] @[subsection]Multiple Assignment:@[subsection] @[code] ( C, A, B, ... ) = ( A, B, C, ... ) ( A, B ) = func(); @[code] the expression in the right side should yield a list or tuple, and each of the elements in the tuple/list is assigned accordingly to each of the variables in the left side. Extra elements in the right side are ignored. @[text] @[name] dao.operator.typecast @[name] @[title] Type Casting Operators @[title] @[text] The values of many types can be converted to values of other types by type casting with: @[code] (typename) value @[code] Most of the primitive types support conversion between each other. Type casting between aggregate types such as tuples, lists and maps are also supported by applying the casting of the items recursively. @[text] @[name] dao.operator.misc @[name] @[title] Miscellaneous Operators @[title] @[text] @[subsection] String operators @[subsection] @[code] string + string # Concatenation; string += string # String appending; string / string # Path-like Concatenation; string /= string # Path-like appending; @[code] For path-like concatenation, the paths do not need to exist. For such operation, @[green]/@[green] and @[green]X:@[green], where @[green]X@[green] is any alphabetical character, are considered as absolute paths. Additionally, paths starting with @[green]$(@[green] (such as @[green]$(HOME)/abc@[green] etc.) are also considered as absolute (note that the right brackets are not checked). All other paths are considered as relative, and for concatenation, @[green]../@[green] will represent one level higher path with respect to the current path. @[subsection] Type Operators @[subsection] @[code] # Operators: ?= ?< value1 ?= value2 # Type equal; value ?< type # Is type of; @[code] @[subsection] Type Operators @[subsection] @[code] # Operators: ?= ?< value1 ?= value2 # Type equal; value ?< type # Is type of; @[code] @[subsection] Ternery operator: ?: @[subsection] @[code] expression1 ? expression2 : expression3 @[code] The value of @[code]expression2@[code] is returned if @[code]expression1@[code] is evaluated to true (non zero), otherwise the value of @[code]expression3@[code] is returned. @[subsection] Miscellaneous operators @[subsection] @[code] # Size operator: % none # Data type size: 0; % int # Data type size: 4 on 32 bits machine, or 8 on 64 bits machine; % float # Data type size: 8 for double precision; % complex # Data type size: 16 (double precision for both parts); % string # Number of characters; % array # Number of elements; % list # Number of items; % map # Number of key-value pairs; % tuple # Number of items; # Complex conjugation operator: ~ complex # Conjugation; # "in" or "not in" operator: int in string # Test if a character is in the string; string in string # Test if the left operand is a substring of the right; any in list # Test if a value is contained in a list; any in map # Test if a key is in a map; any in tuple # Test if a value is in a tuple; int not in string # Test if a character is not in the string; string not in string # Test if the left operand is not a substring of the right; any not in list # Test if a value is not contained in a list; any not in map # Test if a key is not in a map; any not in tuple # Test if a value is not in a tuple; @[code] @[text] @[name] dao.operator.overloading @[name] @[title] Operator Overloading @[title] @[text] Please see @[node]dao.class.operator@[node]. Operator overloading for wrapped C/C++ types is supported in the same way as in Dao classes. @[text]