Skip to content

list (action)

Syntax

list(expression1, expression2,...)

Parameters

expression<#>
A numeric expression.

Returns

A single list consisting of the value parameters.

Description

The list() action returns a list containing the values represented by a given set of expressions. Each expression must evaluate to a numeric value or a list. list expressions are flattened into the larger single list.

Examples

This first example initialize a shared list primes to the first 10 prime numbers.

variables {
    shared list primes
    primes = list(2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
}

In this second example, each agent has a list-variable that is initialized to that agent's ID number, age (as an integer), sex (1 = M, 0 = F), and race code as defined in synthetic population.

variables {
    agent list my_attribute_list
    my_attribute_list = list(id(), age(), 99, 101)
}

In this final example, a new list is built from an existing list.

old_list = list(1, 2, 3)
new_list = list(10, old_list, 20, 30)

After this code, the list new_list will contain the list (10, 1, 2, 3, 20, 30).

See Also