cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Challenge 9 - Finding differences and similarities

The need to create intersections, differences, and unions, comes up when we need to know values in common, exclusive, or unique to two or more data sets. For this month, create three functions:

  1. intersection(aList, bList) – Returns a list of values contained in both aList and bList.
  2. difference(aList, bList) – Returns two lists. The first contains the values in aList that are not in bList, the second contains the values in bList that are not in aList.
  3. union(aList, bList) – Returns a list of all values in aList and bList, removing any duplicates.

For example, if:

aList = {“a”,”b”,”c”,”d”,”e”,”e”}

bList = {“a”,”a”,”c”,”f”,”g”}

then,

intersection(aList,bList) => {“a”,”c”}

difference(aList,bList) => {{“b”,”d”,”e”},{“f”,”g”}}

union(aList,bList) => {“a”,”b”,”c”,”d”,”e”,”f”,”g”}

 

For extra credit, extend intersection and union to take a list of three or more lists.

Last Modified: Dec 21, 2023 1:32 PM
Comments