Lists in @Formula, especially @Member and @IsNotMember
Let us asume we have these lists:
list1 := "red":"yellow":"green"
list2 := "yellow":"red"
list3 := "black":"blue"
list4 := "red":"white"
list5 := "yellow"
Comparison | Effect | Matches for @true | Examples | Result |
---|---|---|---|---|
= | Compares every single value with the same position in the other list. If one list has less elements than the other list, then the shorter list is padded with the last value. In a list of one, that one element is compared with all others. If there is ONE match true is returned. | one match, same position | list1 = list2 list2 = list5 list5 = list1 |
@false @true @true |
*= | Compares every member of the first with every member of the second list. If there is a single match true is returned. In difference to = the position doesn't play a role and there is no padding (needed) | one match, any position | list1 *= list2 list2*= list5 |
@true @true |
! [Expression] | Turns the expression into the opposite. Very clean. Should be always in front. For readability you might want to use brackets | depends on expression | !list1 = list2 !(list1 = list2) !(list2 *= list5) |
@true @true @false |
!= | not equal operator. Compares element by element, padds a shorter list with the last element (same as =). Returns true if one match pair is different. In other words: only returns false if both list have the same members in the same sequence. | one mismatch, any position | list1 != list2 | @true |
*!= | Compared every element from both lists and returns true if it finds one difference. It only will return false if both lists only contain one value (which can be there multiple times, that wouldn't matter) | if one list has 2 different values | "red":"red" *!= "red":"red":"red" list1*!= list2 |
@false @true |
@IsMember | Checks that all members of the first list are available in the second list. The sequence doesn't matter. If there is one element in the first list, that is not in the second list it returns false. | all, any position | @isMember(list2;list1) @isMember(list4;list1) @isMember(list5;list1) |
@true @false @true |
!@IsMember | reversal of @isMember. If there is just one element in the first list that is not in the second list it returns true. | one mismatch, any position | !@isMember(list2;list1) !@isMember(list4;list1) |
@false @true |
@isNotMember | Checks that none of the elements in the first list is in the second list. If just one element is there, but not others it already returns false. So you can't replace !@IsMember with @IsNotMember for lists arguments. | all mismatches, any position | @isNotMember(list2;list1) @isNotMember(list4;list1) |
@false @false |
!@isNotMember | Double negation to make your head spin <g>. Needs only a single match to return true. Equivalent to *= | one match, any position | @isNotMember(list2;list1) @isNotMember(list4;list1) |
@true @true |
Does your head spin now?
Posted by Stephan H Wissel on 30 June 2007 | Comments (4) | categories: Show-N-Tell Thursday