Skip to content

filter_by_index

Syntax

filter_by_index(agent-list, index-list)

Parameters

agent-list
A list expression that evaluates to a list of valid agent ids.
index-list
A list expression that evaluates to a set of valid index values for the agent list.

Returns

The list of items from agent-list whose index in this list matches one of the index_values given in index-list.

Description

This action returns a subset of the given list agent-list. The second argument index-list specifies the index of the agents to return from the list. It is an error if agent-list contains an invalid agent ID, or if index-list contains an index that is outside the bounds of the given agent list.

Examples

The following code assigns the variable new_list to the result of the filter, which is the list list(10,8,6).

agent_list = list(2,10,8,4,6)
index_list = index_values(agent_list, >, agent_list[0] + 3)
new_list = filter_by_index(agent_list, index_list)

See Also