vec_insert

Purpose

Returns a copy of the vector b with the value of its element c replaced by a.

Syntax

d=vec_insert(a, b, c)

Result and argument types

The following table describes the types of the returned value and the function arguments.

d a b c
vector4double double vector4double int

Result value

This function uses the modulo arithmetic on c to determine the element number. For example, if c is out of range, the compiler uses c modulo the number of elements in the vector to determine the element position.

Formula

If ((c MOD 4) EQ 0) Then d[0] = a Else d[0] = b[0]
If ((c MOD 4) EQ 1) Then d[1] = a Else d[1] = b[1]
If ((c MOD 4) EQ 2) Then d[2] = a Else d[2] = b[2]
If ((c MOD 4) EQ 3) Then d[3] = a Else d[3] = b[3]
Notes:
  • MOD is the modulo operator.
  • EQ is the equal operator.

Example

a = 50.0
b = (10.0, 20.0, 30.0, 40.0)
c = 1
d: (10.0, 50.0, 30.0, 40.0)