Set

You might already be familiar with the mathematical concept of sets. I didn’t know I was aware of sets until I found out that sets are what make up Venn diagrams, and I totally get Venn diagrams. A set is basically an array in which duplicates are not allowed (see Listing 5.16). If you want to know all the people who have called you in the last week, you want your phone to show you the set. You don’t care how many times someone called you (duplicates)—you just want to know whether they called you at all. In many programming languages (although not yet JavaScript), sets are built-in composite data types. An entire branch of mathematics is dedicated to sets and the applications thereof. If you come across a programming problem for which you ...

Get Learning to Program now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.