Element of in / not_in
Syntax
collection ::= set | valueDomainName
Input parameters
op |
the operand to be tested |
collection |
the Set or the Value Domain which contains the values |
set |
the Set which contains the values (it can be a Set name or a Set literal) |
valueDomainName |
the name of the Value Domain which contains the values |
Examples of valid syntaxes
ds := ds_2 in {1,4,6}
ds := ds_3 in mySet
ds := ds_3 in myValueDomain
Semantics for scalar operations
The in operator returns TRUE if op belongs to the collection, FALSE otherwise. The not_in operator returns FALSE if op belongs to the collection, TRUE otherwise. For example:
1 in { 1, 2, 3 }
returns TRUE
“a” in { “c, “ab”, “bb”, “bc” }
returns FALSE
“b” not_in { “b”, ”hello”, ”c”}
returns FALSE
“b” not_in { “a”, ”hello”, ”c”}
returns TRUE
Input parameters type
op
dataset {measure<scalar> _}
| component<scalar>
| scalar
collection
set<scalar> | name<value_domain>
Result type
result
dataset { measure<boolean> bool_var }
| component<boolean>
| boolean
Additional Constraints
The operand must be of a basic scalar data type compatible with the basic scalar type of the collection.
Behavior
The in operator evaluates to TRUE if the operand is an element of the specified collection and FALSE otherwise, the not_in the opposite.
The operator has the typical behaviour of the “Operators changing the data type” (see the section “Typical behaviours of the ML Operators”).
The collection can be either a set of values defined in line or a name that references an externally defined Value Domain or Set.
Examples
Given the operand dataset DS_1 and the Value Domain named myGeoValueDomain (which has the basic scalar type string) defined by {“AF”, “BS”, “FJ”, “GA”, “KH”, “MO”, “PK”, “QA”, “UG”}:
Input DS_1 (see structure)
Id_1 |
Id_2 |
Me_1 |
---|---|---|
2012 |
BS |
0 |
2012 |
GZ |
4 |
2012 |
SQ |
9 |
2012 |
MO |
6 |
2012 |
FJ |
7 |
2012 |
CQ |
2 |
Example 1
DS_r := DS_1 in { 0, 3, 6, 12 };
results in (see structure):
Id_1 |
Id_2 |
bool_var |
---|---|---|
2012 |
BS |
True |
2012 |
GZ |
False |
2012 |
SQ |
False |
2012 |
MO |
True |
2012 |
FJ |
False |
2012 |
CQ |
False |
Example 2
DS_r := DS_1 [ calc Me_2:= Me_1 in { 0, 3, 6, 12 } ];
results in (see structure):
Id_1 |
Id_2 |
Me_1 |
Me_2 |
---|---|---|---|
2012 |
BS |
0 |
True |
2012 |
GZ |
4 |
False |
2012 |
SQ |
9 |
False |
2012 |
MO |
6 |
True |
2012 |
FJ |
7 |
False |
2012 |
CQ |
2 |
False |
Example 3
DS_r := DS_1#Id_2 in myGeoValueDomain;
results in (see structure):
Id_1 |
Id_2 |
bool_var |
---|---|---|
2012 |
BS |
True |
2012 |
GZ |
False |
2012 |
SQ |
False |
2012 |
MO |
True |
2012 |
FJ |
True |
2012 |
CQ |
False |