The ALTernative Language
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Fold

You can fold over unions and sequences with five different (prefix) fold operators:

  • \+: sum
  • \*: product
  • \&: all
  • \;: catenate
  • \|: or

These operators allow you to calculate sums and products, and to turn unions into sequences or vice versa.

Sum numbers

S1:
S2:

Convert union to sequence

C1:

Convert sequence to union

C2:

Intersect a sequence of structs