Experimentation with List Functions
Want to show various ways of showing items which are in one list and not another. Here are a couple of lists from which the examples below work from:
- Set LONGERLIST = Apple, Pear, Sultana, Raison, Banana,
- Set SHORTERLIST = Apple, Pear, Banana, Kiwi
Also see the following items related to lists and in particular, working with Groups of people:
Item
Support.Question91,
Support.Question92 and
Support.Question93 for items covering fetching Variables from other pages and recovering Group members as well as
p AND ¬q
So....Comparing
%LONGERLIST% to
%SHORTERLIST%, I want to see Sultana and Raison as the rest of the shorter list is in longer list.
The formula I came up with is:
%CALC{"$LISTIF($NOT($COUNTSTR(%SHORTERLIST%,$item)), %LONGERLIST%)"}%
and the result is:
Sultana, Raison
¬p AND q
%CALC{"$LISTIF($NOT($COUNTSTR(%LONGERLIST%,$item)), %SHORTERLIST%)"}%
and the result is:
Kiwi
Yippee!!
--
NeilGood - 14 Mar 2009
Neat trick! Of course to make this a complete reference, there are
a few more cases to consider. I'll take a couple of easy ones
--
SeanMorgan - 15 Mar 2009
p OR q
%CALC{$LISTUNIQUE(%SHORTERLIST%,%LONGERLIST%)}%
and the result is:
Apple, Pear, Banana, Kiwi, Sultana, Raison
p AND q
%CALC{"$LISTIF($COUNTSTR(%SHORTERLIST%,$item), %LONGERLIST%)"}%
and the result is:
Apple, Pear, Banana
p XOR q
In this case the list should be
Sultana, Raison, Kiwi and can be obtained through a combination of the above....just need a few more mins sometime to work through it:
Set(
ListCombined? ,$LISTUNIQUE(Apple, Pear, Banana, Kiwi,Apple, Pear, Sultana, Raison, Banana, ))
Set(
ListCommon? ,$LISTIF($COUNTSTR(Apple, Pear, Banana, Kiwi,$item), Apple, Pear, Sultana, Raison, Banana, ))
,ListCombined)
--
NeilGood - 15 Mar 2009