setarray
setarray(a_arrayx_indexg_value) =>g_valuesetarray(o_tableg_keyg_value) =>g_value
Description
Assigns the given value to the specified element of an array or to the specified key of a table. Normally this function is invoked implicitly using the array-subscription syntax, such as, x[i] = v.
Assigns g_value to the x_index element of a_array, or adds the association of g_value with g_key to o_table, and returns g_value. Normally this function is invoked implicitly using the array-subscription syntax, such as, x[i] = v.
Arguments
|
Index of the array element to assign a value to. Must be between 0 and one less than the size of the array. |
|
|
Value to be assigned to the specified array element or table entry. |
Value Returned
|
Value assigned to the specified array element or table entry. |
Examples
declare(myar[8])
=> array[8]:3895304
myar[0]
=> unbound
setarray(myar 0 5)
=> 5
myar[0]
=> 5
setarray(myar 8 'hi)
Signals an array bounds error.
setarray(myar
(plus 1 2) ; assigns element 3 the value 8.
(plus 3 5))
=> 8
mytab = makeTable('myTable)
=> table:myTable
setarray(mytab 8 4)
=> 4
mytab[8]
=> 4
mytab[9] = 3
=> 3 ; same as setarray(mytab 9 3)
mytab[9]
=> 3
Related Topics
Return to top