Skip to content

set

Syntax

set(x,y)
set(x, index, value)
set(x, index-list, value)

Parameters

x
A name of a variable, a list-variable or a table variable.
y
An expression with the same type as x.
index
An expression who value is treated as an index if x is a list-variable an as a key if x is a table variable.
index-list
A list-expression who values are treated as a single compound key if x is a table variable.
value
A expression that evaluates to a numeric value.

Description

This action updates a variable, a list element, or one or more items in a table.

The user usually invokes this action using the = sign as shown below:

x = y    # translates to set(x,y)
Some_list[index] = value       # translates to set(Some_list, index, value)
Some_table[index] = value      # translates to set(Some_table, index, value)
Some_table[index-list] = value # translates to set(Some_table, index-list, value)

A compiler error results if the type or number of arguments is not consistent with the type of the first argument.

Examples

Give one or more examples of this item.

my_y = x * 2
my_friend_list = some_list_of_agents
my_friend_list[10] = some_agent_id
my_lookup_table = some_other_table
my_lookup_table[some_agent_id] = ask(agent_id, age)

# this sets the value in the table with the compound key "list(id1, id2)" to 300
my_lookup_table[list(id1, id2)] = 300

Note

my_lookup_table[list(id1)] = 5 is equivalent to my_lookup_table[id1] = 5

See Also