Advanced Knowledge: Multi-Assignments

The multi-assignment allows to extract elements from a list into different variables. It is similar to the head-tail-notation of Prolog but here we can create complex structures.

variablelistASSIGNexecutable_term

Example:

The examples creates a list of numbers within the range [1,20) and similar to the deconstruct operator assigns the numbers of the list to variables.

L = collection/list/range(1, 20);
[A|B|C|_|D|E|F|G] = L;
Resulting in

  • A ← 1
  • B ← 2
  • C ← 3
  • (the garbage bin variable _ causes the number 4 to be ignored)
  • D ← 5
  • E ← 6
  • F ← 7
  • G ← [8, … 19]