Singletons
- Last Updated: March 24, 2022
- 2 minute read
- Corticon
- Version 6.3
- Documentation
Singletons are collection operations that iterate over a set to extract one
arithmetic value: the first, the last, the trend, the average, or the element at a
specified position. This behavior was seen when the sortedAlias found the first and last element in an iterative list (as well as
the elements in between) in the given order.
To examine this feature, the Aircraft entity
and its maxCargoWeight is brought into the scope as well as
Cargo (with the alias load) and its attribute weight. The
nonconditional action you enter is:
"Show me the maximum cargo weight by examining all the cargo in the load, sorting them by weight from small to large, and returning the smallest one first."
That is entered as:
Aircraft.maxCargoWeight=load->sortedBy(weight)->first.weight
When you extend the test used for sorted aliases, you need to add an Aircraft with maxCargoWeight
to show the result of the test. The result is as expected: the lightest item passed the
test.
The same result is output when you modify the rule to select the last item when you sort the items by descending weight.
Now, reverse the test to select the first item when you sort the items by descending weight:
The heaviest item is output: