| Navigation : Previous | Next | 
Count : Counting Items
 Count is a counter. Its internal value
increases at each evaluation evaluated, if the input value is non nil.
 Count is a counter. Its internal value
increases at each evaluation evaluated, if the input value is non nil.
Inputs and Outputs

Count has one default input and three outputs :
- “what” : a value.
- first output : triggers the increment of the counter if the input is non nil, and returns its current value.
- second output : returns the current state of the counter.
- third output : resets the value of the counter to zero.
Examples
Counting the Items of a List
- 
    Listloop returns each element of the list successively to count. These elements are non nil values. 
- 
    The first output of count adds 1 every time listloop returns an element. 
- 
    Once the enumeration of listloop is over, the final state of count is returned by Finally. 

Counting Specific Items of a List
We will now apply count more specifically, to know how many strings a list contains among other types of items.

- 
    Listloop enumerates the elements of a list. 
- 
    The stringp predicate returns true every time it evaluates a string. 
- 
    At each step of the loop, the first output of count is evaluated : 
* if it gets a non nil value from **stringp**, it increments the value of the counter
* if it gets "nil", the value doesn't change.   4. The results returned by **stringp** and counter are gathered in a list and printed.
- The total number of strings, that is, the final state of counter is returned by Finally.
Contents :
- OpenMusic Documentation
- OM User Manual
- OpenMusic QuickStart
| Navigation : Previous | Next |