Skip to content

Operations on instance sets

Leon Starr edited this page Nov 6, 2023 · 2 revisions

Operations on instance set variables

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.

Set operations

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

Introduction

Model semantics

Flows (as Variables)

Constants and literals

Structure of an activity

Accessing the class model

Data flow


Grammar and parsing notes

Components

Clone this wiki locally