collect_if(group,condition,attribute)

Tinderbox Icon


Operator Type:   Function
Operator Scope of Action:   Conditional Group
Operator Purpose:   List creation

A function collect_if() builds a List (prior to v5.6.0 it was a Set); see collect() for a related new operator.

collect_if(group,condition,attribute)

builds a set by collecting all the notes corresponding to group, testing each note to see if it meets condition, and adding the value of the designated attribute to the set.

group may be any of {children,descendants,siblings,ancestors,all}. In addition, group may be argument that designates a particular (single) note other than this.

condition is a valid conditional test - i.e. it equates to true when matched.

attribute can be any expression, but is typically an attribute.

For example,

collect_if(children,$Status=="Important",$Name) 

will construct a set of the names of all of this note's important children.

Note that collect_if's function is related to agents; many tasks you might perform with collect_if could be done as well, or better, with an agent.

If a list of unique values is required - i.e. a set rather than a list, simply pass the output to a Set attribute. Thus if:

$MyList = collect_if(children,$Age>6,$FavFruit) $MyList is "Apples;Oranges;Pears;Apples"

$MySet = collect(children,$Age>6,$FavFruit) MySet is "Apples;Oranges;Pears;"


Possible relevant notes (via "Similar Notes" feature):

Up: Full Operator List
Previous: collect(group,attribute)  Next: Color.blue 

A Tinderbox Reference File : Actions & Rules : Operators : Full Operator List : collect_if(group,condition,attribute)

Quicklinks: Attributes | Action Codes | Export Codes | Designators | Date Formats | aTbRef Site Map

[Last updated: 16 May 2012, using v5.11.1]


Search:

Google search aTbRef for:  


Creative Commons Licence

aTbRef by Mark Anderson is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

[See aTbRef CC licence Attribution & Waiver info]

Made with Tinderbox