set()

An action that implements an assignment operation.

Synopsis

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

Description

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

The user usually invokes this function using a shortcut notation, 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)

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 list of keys if x is a table variable.

value

A expression that evaluates to a numeric value.

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)

Errors

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

See Also

list(), table, variables