8.5.1   General Features of Tuple Operations

Please note that in all following tables variables and constants have been substituted by letters which indicate allowed data types. These letters provide information about possible limitations of the areas of definition. The letters and their meaning are listed in table 8.6. Operations on these symbols can only be applied to parameters of the indicated type or to expressions that return a result of the indicated type.

The symbol names i, a, b, and s can denote atomic tuples (tuples of length 1) as well as tuples with arbitrary length.

Symbol Types

i integer
a arithmetic, that is: integer or real
b boolean
s string
v all types (atomic)
t all types (tuple)

Table 8.6: Symbols for the operation description.

Operations are normally described assuming atomic tuples. If the tuple contains more than one element, most operators work as follows:

In table 8.7 you can find some examples for arithmetic operations with tuples. Pay special attention to the order in which the string concatenations are performed. The basic arithmetic operations in HDevelop are +, -, *, /. Please note that + is a dimorphic operation: If both operands are numeric, it adds numbers. If at least one of the operands is a string, it concatenates both operands as strings.

Input Result

5 * 5 25
[5] * [5] 25
[1,2,3] * 2 [2,4,6]
[1,2,3] * 2.1 + 10 [12.1,14.2,16.3]
[1,2,3] * [1,2,3] [1,4,9]
[1,2,3] * [1,2] runtime error

'Text1' + 'Text2' 'Text1Text2'
17 + '3' '173'
'Text ' + 3.1 * 2 'Text 6.2'
3.1 * (2 + ' Text') runtime error
3.1 + 2 + ' Text' '5.1 Text'
3.1 + (2 + ' Text') '3.12 Text'

Table 8.7: Examples for arithmetic operations with tuples and strings.