Sets versus Lists

<p><a href="https://www.prepswift.com/quizzes/quiz/prepswift-sets-versus-lists" target="_blank">Sets versus Lists Exercise</a></p><p>In previous mountain entries, I kept using the word &quot;dataset&quot; to avoid saying the words &quot;set&quot; or &quot;list.&quot; So, without further adieu, I present <strong><span style="color:#8e44ad;">Sets Versus Lists</span></strong>.</p> <p><strong><span style="color:#e74c3c;">Key Differences</span></strong></p> <ul> <li><strong><span style="color:#2980b9;">NOTATION</span></strong> <ul> <li>A list is written either without brackets or with square brackets. <ul> <li>$1, 2, 3$ or $[1, 2, 3]$</li> </ul> </li> <li>A set is written with cute curly brackets. <ul> <li>$ \{1, 2, 3 \}$</li> </ul> </li> </ul> </li> <li><strong><span style="color:#2980b9;">ORDER</span></strong> <ul> <li>A list&#39;s elements are in order. That doesn&#39;t necessarily mean &quot;low to high.&quot; It means that the first element in the list is ALWAYS at the front of the list. For example, the two lists below are different: <ul> <li>$[1, 2, 3] \neq [2, 3, 1]$</li> </ul> </li> <li>A set&#39;s elements have no order. For example, the two sets below ARE EQUAL to each other: <ul> <li>$ \{ 2, 3, 5, 7 \} = \{ 3, 7, 2, 5 \}$</li> </ul> </li> </ul> </li> <li><strong><span style="color:#2980b9;">REPEATED ELEMENTS</span></strong> <ul> <li>A list <u>allows repeats</u>. For example, the list $[1, 1, 1]$ has three elements: a $1$ in the first position, a $1$ in the second position, and a $1$ in the third position.</li> <li>A set does NOT count repeats. For example, the two sets below ARE THE SAME. <ul> <li>$\{1, 1, 1, 1, 1\} = \{1\}$</li> </ul> </li> </ul> </li> <li><strong><span style="color:#2980b9;">FINITE OR INFINITE?</span></strong> <ul> <li>A list is always finite.</li> <li>A set can be either. <ul> <li>Example Finite Set: The set of all positive integers less than $100$.</li> <li>Example Infinite Set: The set of all positive integers greater than $100$.</li> </ul> </li> </ul> </li> </ul>