Date tip published: | 01/19/2004 |
Description: | Built into the formula language are many @functions and operators that deal with lists. There are two types of list operators, pair-wise and permutation. This tip will explain the difference between these two list operations. |
To learn more about the Notes Domino formula language and lists use the following links:
Notes Domino 6 Application Development 1
Notes Domino 6 Application Development 2
Pair-wise and Permutation Operations
Notes provides a set of pair-wise and permutation operators for lists. For the pair-wise operators, the operation is evaluated in pairs, with the first element of the first list paired in operation with the first element of the second list, and so on. With the permutation operators, each element in the first list operates with each element in the second list.
The following description of the pair-wise and permutation operators is copied here from Lotus Domino Designer 6 Help.
From Lotus Domino Designer 6 Help |
|
Operations on lists
Operations on lists are of two types:
- Pair-wise -- Pairwise operators act on two lists in parallelelement fashion. The first element of list 1 pairs with the first element of list 2, the second element of list 1 pairs with the second element of list 2, and so on. If one list has fewer elements than the other, the last element in the shorter list is repeated for operations with the remaining elements of the longer list. If list 1 consists of "A":"B":"C" and list 2 consists of "1":"2," the operation is performed as though list 2 contained "1":"2":"2." For pairwise equality tests, only one match is needed for the statement to return True, or 1.
- Permuted -- Permutation operators act on two lists, pairing every possible combination of their values. The resulting list has an element for each pairing in the following order: list 1 element 1 paired with each element in list 2, list 1 element 2 paired with each element in list 2, and so on through the last element in list 1.
If an operation occurs on a list and a non-list value, the non-list value is paired with each element in the list.
The table below shows the pairwise and permutation operators.
Pair-wise operator | Permutation operator | Meaning |
* | ** | Multiplication |
/ | */ | Division |
+ | *+ | Addition |
- | *- | Subtraction |
> | *> | Greater than |
< | *< | Less than |
>= | *>= | Greater than or equal to |
<= | *<= | Less than or equal to |
= | *= | Equal |
!= | *!= | Not equal |
|
Pair-wise Equality
A common list operation is to test if any members of one list are also members of another list. Consider this pair-wise equality expression:
"Tokyo" : "Paris" = "Toronto" : "London" : "Paris" |
On the surface, it does not appear that the above expression is TRUE, but it is when considered in a pair-wise manner. Remember that in a pair-wise operation the last element of the shorter list is repeated for operation with the remaining elements in the longer list. The graphic below demonstrates how Notes evaluates this pair-wise expression. The comparison is TRUE when one of the evaluated pairs is equal.
Permutation Equality
In a permutation equality expression, each element of the first list is compared to each element of the second list. Consider this permutation equality expression:
"Tokyo" : "Toronto" *= "Toronto" : "London" : "Paris" |
Although this expression would evaluate to FALSE if it were evaluated as a pair-wise comparison, it is TRUE when evaluated as a permutation comparison. The graphic below demonstrates how Notes evaluates this permutation expression.
|