Expressions


So far, every input of an Operator needed its own Variable Card, so even a small calculation could require a large number of cards. To avoid this problem, an expression allows you to place a whole calculation in a single Variable Card. Expressions can contain raw values, other Operators and references to other cards.

Start by opening the Logic Programmer and selecting the Arithmetic Addition Operator. Instead of inserting Variable Cards, click its first input slot, type 3 and press Enter, and do the same with 4 for its second slot. Write the result to a Variable Card. Its tooltip shows the expression you just created: 3 + 4.

Inputs can also hold other Operators. To do this, select an input slot, and the list on the left only shows the Operators that would fit. Pick one, such as Arithmetic Multiplication, and it is placed inside the slot and opened, so you can fill the inputs of that other operator. The breadcrumb tabs at the top show you the location in nested operators. To complete the next part of the tutorial, write an expression with an Operator inside another one and bind it to a Variable Card, such as (2 * 5) + 4.

Finally, expressions can have Parameters, which allow you to create custom Operators. To do this, open the panel with the arrow button at the top right of the Logic Programmer and type (n: Integer) => n > 10, or use its + Parameter button and drag the parameter into a slot. Next, write it to a Variable Card, and put it in a Variable Store together with a List of Integers, such as 1, 20 and 5. Then filter that List with your Operator using the Filter Operator, and show the result in a Display Panel.

Additionally, expressions can also refer to other cards by their ID, via the #5 syntax. If you want to exchange expressions across worlds, it is not recommended to refer to them by ID, but by label using Labeller, for which you can use the same syntax. Have a look at the Expressions page in the manual to learn more about what types of expressions you can write.

Operator
FilterfilterFilter a list of elements by matching them all with the given predicate.
  • Operátor
  • Seznam
  • Seznam
Globální jméno: operatorFilter(Operátor, Seznam) → SeznamJméno metody: Operátor.filter(Seznam) → Seznam
Advancements
  • Leveraged ExpressivityCreate a §eVariable Card§7 that contains an expression, such as 3 + 4.
  • Expressive Operator NestingCreate an expression with an §eOperator§7 inside another one.
  • Expressive Custom OperatorsCreate a new operator by writing an expression with a §eParameter§7, pass it to an §eOperator§7 such as Filter, and display the result.
Rewards
Labeller1
Úložiště proměn1
Display Panel4
Proměnná karta16