Details of Icon Infix Operations (part 2)


x1 := x2 : x1 -- assign value

x1 := x2 assigns the value of x2 to x1 and produces the variable x1.
See also: x1 op:= x2, x1 :=: x2, x1 <- x2, and x1 <-> x2

x1 op:= x2 : x1 -- augmented assignment

x1 op:= x2 performs the operation x1 op x2 and assigns the result to x1; it produces the variable x1. There are augmented assignment operators for all infix operations except assignment operations.
See also: x1 := x2

x1 :=: x2 : x1 -- exchange values

x1 :=: x2 exchanges the values of x1 and x2 and produces the variable x1.
See also: x1 := x2 and x1 <-> x2

x1 <- x2 : x1 -- assign value reversibly

x1 <- x2 assigns the value of x2 to x1 and produces the variable x1. It reverses the assignment if resumed.
See also: x1 := x2 and x1 <-> x2

x1 <-> x2 : x1 -- exchange values reversibly

x1 <-> x2 exchanges the values of x1 and x2 and produces the variable x1. It reverses the assignment if resumed.
See also: x1 <- x2 and x1 :=: x2

i1 to i2 by i3 : i1, ..., in -- generate integers in sequence

i1 to i2 by i3 generates the sequence of integers from i1 to i2 in increments of i3.
Default:
i3      1 if by clause omitted

See also: seq()

[x1, x2, ..., xn] : L -- create list

[x1, x2, ..., xn] produces a list containing the values x1, x2, ..., xn. [] produces an empty list.
See also: list()

x1[x2] : x3 -- subscript

If x1 is a string, x[x2] produces a one-character string consisting of character x2 of x1. x1[x2] fails if x2 is out of range. x1[x2] produces a variable if x1 is a variable.

If x1 is a list, x1[x2] produces element x2 of x1.

If x1 is a record, x1[x2] produces a field of x1 according to x2: if x2 is an integer, the x2th field is produced; if x2 is a string, the field named by the value of x2 is produced.

If x1 is a table, x1[x2] produces the element corresponding to key x2 of x1.

In all cases, x2 may be nonpositive.

In all cases, the subscripting operation fails if the subscript is out of range.

See also:
x1[x2,x3, ..., xn], x[i1:i2], x[i1+:i2], and x[i1-:i2]

x1[x2,x3, ..., xn] : x -- multiple subscript

x1[x2,x3, ..., xn] is equivalent to x1[x2][x3]...[xn].
See also: x1[x2]

x1[i1:i2] : x2 -- produce substring or list section

If x1 is a string, x1[i1:i2] produces the substring of x1 between i1 and i2. x1[i1:i2] produces a variable of x1 is a variable.

If x1 is a list, x1[i1:i2] produces a list consisting of the values of x1 in the given range.

In either case, i1 and i2 may be nonpositive.

In either case, the subscripting operation fails if a subscript is out of range.

See also: x[i], x[i1+:i2], and x[i1-:i2]

x1[i1+:i2] : x2 -- produce substring or list section

If x1 is a string, x1[i1+:i2] produces the substring of x1 between i1 and i1 + i2. x1[i1+:i2] produces a variable of x1 is a variable.

If x1 is a list, x1[i1+:i2] produces a list consisting of the values of x1 in the given range.

In either case, i1 and i2 may be nonpositive.

In either case, the subscripting operation fails if a subscript is out of range.

See also: x[i], x[i1:i2], and x[i1-:i2]

x1[i1-:i2] : x2 -- produce substring or list section

If x1 is a string, x1[i1-:i2] produces the substring of x1 between i1 and i1 - i2. x1[i1-:i2] produces a variable of x1 is a variable.

If x1 is a list, x1[i1-:i2] produces a list consisting of the values of x1 in the given range.

In either case, i1 and i2 may be nonpositive.

In either case, the subscripting operation fails if a subscript is out of range.

See also: x[i], x[i1:i2], and x[i1+:i2]