collect(group,attribute)

Tinderbox Icon


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

collect(group,attribute)

A function collect() builds a List (prior to v5.6.0 it was a Set) by visiting each note described by group and adding the value of the designated attribute to the set. See collect_if() for a related new operator.

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.

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

For example,

collect(children,$Name) 

constructs a set with the name of each child of the note.

For example,

collect(children(/agents/books),$Name) 

does the same for children of the note 'books' inside 'agents'.

collect(children,$Width * $Height) 

collects a series of numerical values of each child's map icon height/width in Tinderbox map units. Thus if a child had a $Width of 4 and $Height of 2, the collect() result for that item would be 8.

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(children,$FavFruit) $MyList is "Apples;Oranges;Pears;Apples"

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


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

Up: Full Operator List
Previous: capitalize(data)  Next: collect_if(group,condition,attribute) 

A Tinderbox Reference File : Actions & Rules : Operators : Full Operator List : collect(group,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