-
Notifications
You must be signed in to change notification settings - Fork 0
Operations on instance sets
Use the cardinality (how many are there) symbol ?? to obtain the cardinality of an instance set variable.
qty priority tasks = ??next tasks
The result is a positive integer.
Basic set operations such as union, intersection, subtraction (set complement) are supported on instance sets of the same class.
Here the variables r, a and b are instance sets of the same class:
r ..= a ^ b // intersect (since there is a space between ^ and b)
r ..= a + b // union
r ..= a - b // subtract
r ..= a % b // symmetric difference
quantityOfR = ??r // total number of instance references
Super and subset operations yield a boolean result:
( c < d) {
// is c a proper subset of d?
// if so, take action here
}
The symbols are <, <_, > and _> for proper subset, subset, proper superset and superset. The set operators might look a bit strange, especially since some of them double as scalar value comparison operators, but they are easy to type and a modern text editor can replace these symbols with the corresponding math set characters ⊂, ⊆, ⊇, ⊃ .
Here are some more examples:
// Grab some aircraft instance references
fastest aircraft ..= Aircraft( Airspeed > min speed )
highest aircraft ..= Aircraft( Altitude > floor alt )
// Now let's do some set operations on them
slow aircraft ..= Aircraft - fastest aircraft // set complement from class population
high and fast aircraft ..= fastest aircraft ^ highest aircraft // intersection
fastest low aircraft ..= fastest aircraft - highest aircraft // set complement
my aircraft .= /Aircraft( Tail number: my tail number )
my aircraft and slowest aircraft ..= my aircraft + slow aircraft // single instance in union
qty of slow aircraft = ??slow aircraft
Copyright 2020, 2021, 2022, 2023, 2025 © Leon Starr under MIT Open Source License
- Why they are problematic
- Instance attribute creation values
- Boolean values
- Special values
- Enumerated values
- Action block
- Statement
- Single line action
- Multiple dependent actions on a single line
- An action spread across multiple lines
- A conditional group of single line actions
- Comments
- Finding instances
- Attribute access
- Creation and deletion
- Subclass migration
- Creating a table from a class
- Creating a table with a definition
- Converting a table into a class
- Set operations on tables
- Set comparisons on tables
- Join
- Rename
- Extend
- Aggregation
- Rank
- Image
- Input values
- Signatures and name doubling
- Output values
- Execution order
- Sequential execution
- Conditional execution
- Signals
- Scrall has no for_each action
- Iteration