cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

JMP Challenge

Challenges that focus on the JMP Scripting Language and occasionally, some that can be done without scripting.
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