Flows
A Flow names a computation. Reading it computes a Bag from data, without changing any data.
Name a computation
Section titled “Name a computation”def declares a Flow. Other Flows can use its name:
def colors = {"red", "blue", "blue"}def color_names = colors%color_names // {"blue", "red"}Name steps with let
Section titled “Name steps with let”Inside braces, let names an intermediate result. The name is available after its let, and it cannot change:
def built = { let first! num = 1 let second! num = first + 1 {first, second}}built // {1, 2}The braces collect their expressions into one result Bag. A let names a result without adding it to that Bag.
State a contract
Section titled “State a contract”SakaQL works out each Flow’s Set and cardinality from its expression. You can also state a contract, and the result must fit it:
def one! num = 1def maybe? str = "red"def flags* bool = {true, false}def few: num'0..3 = {1, 2}def wrong! num = {1, 2} // error SK4301wrong promises exactly one number but computes two.