index_agents()

Returns a list of indexes of agents from a list that satisfies the test argument.

Synopsis

index_agents(agent-list, test)

Description

Returns a list of indexes of agents from a list that the test argument. The test can consist of multiple conditions.

In the test expressions, agent properties refer to the evaluating agent while the special variable “_” refers to the evaluated agent from the given list. For example, the test expression age < ask(_,age) would compare the evaluating agent’s age against the age of each agent in the list.

Parameters

agent-list

A list expression that evaluates to a list of agent ids.

test

A boolean expression used to evaluated the current agent against the given list of agents.

Returns

A list of indexes of agents from agent-list that satisfies the test argument.

Examples

The following sets the list my_list to the list of indexes of agents from the evaluating agent’s school who are male and older than 15:

my_list = index_agents(members(School), ask(_,sex)==male & ask(_,age)>15)

See Also

filter_agents() filter_by_index() filter_values() index_values() list() pair-expression