-
Notifications
You must be signed in to change notification settings - Fork 0
Understand multi‐values
In FuncSug, you don't work with values but with multi-values! What is that?
I'm going to explain that to you.
Each expression results in possibly multiple values. The set of these value(s) is named a multi-value.
Ditto for variables: They can hold multiple values. The set of these value(s) is the multi-value of the variable.
Enough with theory! Place to practice!
I declare a variable:
var myVariable
At the moment just after the declaration, the variable myVariable
doesn't contain any value! Yes, no value, NOT a null value, NOT an undefined value as in classical languages! The set of values of the variable is empty.
Now, if I run:
myVariable := 34
Then, the variable contains exactly one value: 34. This case is exactly as in classical languages.
For getting more than one value, I have to demand for multiple values! 😋 Here is the syntax: par(45, 23, 56)
. Yes, I demand for several values in parallel!
If I run:
myVariable := par(45, 23, 56)
Now, myVariable
contains three values. The set of these three values is called a multi-value and is noted |45, 23, 56|
.
Here are the syntaxes:
- To get 0 value:
par()
or| |
or an uninitialized variable - To get 1 value:
par(34)
or34
or|34|
(Yes, it's exactly the same!) - To get 2 or more values:
par(45, 23, 56)
or|45, 23, 56|
Important
I name multi-value the set of the whole content of a variable. That might be a N-value multi-value (N is 0, 1, 2 or more).
Tip
You can exercise with this console.
With most operations, the operation is done with all possible combinations. For example, |100, 200| + |3, 4|
gives |103, 104, 203, 204|
.
But there are exceptions: par(|100, 200|, |3, 4|)
gives |100, 200, 3, 4|
(It's just concatenation) and seq(|100, 200|, |3, 4|)
gives |3, 4|
(It's just the last argument).
Caution
Operations with | |
can be very misleading! |3, 4| + | |
gives | |
(Note that it's really all the possible combinations).
FuncSug Documentation