Algosim documentation: SetValue

SetValue

Sets a value in a structure.

Syntax

Description

Let S be a structure and x any object. If s is the name of a member of S, then SetValue(S, s, x) returns S with the value of the member s set to x. If i is a valid index for a member in S, then SetValue(S, i, x) returns S with the value of the member with index i set to x.

Examples

struct("a": 3, "b": 10)
a: 3
b: 10
SetValue(ans, "b", 20)
a: 3
b: 20

Notes

This is a purely functional function. Typically, one uses the assignment operator to change a value in a structure lvalue:

S ≔ struct("a": 3, "b": 10)
a: 3
b: 10
S.b ≔ 20
20
S
a: 3
b: 20

See also