load help; @[name] dao.operator @[name] @[title] 运算符 @[title] @[text] 道语言支持丰富的运算符,以支持写表达能力强的代码。 很多运算符可用在不同的数据类型上。 值得注意的是:那些以数值数组为运算子的运算都是基于元素的, 如数组之间的乘法则是对应元素之间的乘法。 @[text] @[name] dao.operator.arithmetic @[name] @[title] 算术运算符 @[title] @[text] @[code] # 二元运算符: (int|float|complex|array) + (int|float|complex|array) # 加法; (int|float|complex|array) - (int|float|complex|array) # 减法; (int|float|complex|array) * (int|float|complex|array) # 乘法; (int|float|complex|array) / (int|float|complex|array) # 除法; (int|float|array) % (int|float|array) # 取模; (int|float|array) ** (int|float|array) # 幂次; # 一元运算符: + (int|float|complex|array) # 一元加法; - (int|float|complex|array) # 一元减法; ++ (int|float|complex|array) # 前缀式自增; -- (int|float|complex|array) # 前缀式自减; @[code] @[text] @[name] dao.operator.comparison @[name] @[title] 比较运算符 @[title] @[text] @[code] (int|float) == (int|float) # 等于; (int|float) != (int|float) # 不等于; (int|float) < (int|float) # 小于; (int|float) > (int|float) # 大于; (int|float) <= (int|float) # 小于等于; (int|float) >= (int|float) # 大于等于; complex == complex # 等于; complex != complex # 不等于; array == array # 等于; array != array # 不等于; array(|) < array(|) # 小于; array(|) > array(|) # 大于; array(|) <= array(|) # 小于等于; array(|) >= array(|) # 大于等于; string == string # 等于; string != string # 不等于; string < string # 小于; string > string # 大于; string <= string # 小于等于; string >= string # 大于等于; @[code] @[text] @[name] dao.operator.logic @[name] @[title] 逻辑运算符 @[title] @[text] @[code] ! (int|float) # Logic negation (NOT); not (int|float) # Logic negation (NOT); (int|float) && (int|float) # Logic AND; (int|float) and (int|float) # Logic AND; (int|float) || (int|float) # Logic OR; (int|float) or (int|float) # Logic OR; @[code] @[text] @[name] dao.operator.bitwise @[name] @[title] 比特运算符 @[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] 赋值运算符 @[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 are ignored. @[text] @[name] dao.operator.typecast @[name] @[title] 类型转换操作符 @[title] @[text] 很多类型的值可以通过以下类型映射操作符转换为其他类型的值: @[code] (typename) value @[code] 大部分基本类型支持相互间的转换。元组,列表和哈希表等复合类型的类型转换 则通过递归地转换他们的元素而实现。 @[text] @[name] dao.operator.misc @[name] @[title] 其它运算符 @[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] Ternery operator: ?: @[subsection] @[code] expression1 ? expression2 : expression3 @[code] The value of @[cyan]expression2@[cyan] is returned if @[cyan]expression1@[cyan] is evaluated to true (non zero), otherwise the value of @[cyan]expression3@[cyan] 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] 运算符重载 @[title] @[text] 请参看@[node]dao.class.operator@[node]. 封装的C/C++类型的运算符重载支持跟Dao类的支持基本一样。 @[text]