This page does not represent the most current semester of this course; it is present merely as an archive.

In this class, we will deal with some atomic values: true, false, and numbers. We will also deal with some composite values: sets and sequences. We call them composite because they are made up of other values.

Both sets and sequences

  • May contain any other value, including other sets and sequences
  • Are values, not entities
  • Are used to define other structures of interest in this course
  • Are commonly written with their contained values separated by commas

However, sets and sequences differ in several important ways:

Set Sequence
Written with curly braces, like \{1,2\} Written with parentheses, like (1,2)
Cannot contain the same value more than once; writing \color{darkred} \{1,1\} doesn’t make sense Can contain the same value any number of times; (1,1) is a sequence and is distinct from (1) and (1,1,1)
Members have no order; \{2,3\} = \{3,2\} Items have order; (2,3) \ne (3,2)
The number of members in a set is called its cardinality The number of items in a sequence is called its length
The empty set (the only set with cardinality 0) is written \{\} or \emptyset The empty sequence (the only sequence with length 0) is written () or \epsilon \varepsilon
Has many operators and special notations like \{1,2\} \cup \{x^2 \;|\; x \in \mathbb N^{+}\} Has no operators that are commonly used in computing
A singleton set is always distinct from its member; \{2\} \ne 2 A singleton sequence is often considered equal to its item; (2) = 2
Always called set Called sequence or tuple, with special words for some lengths (e.g. pair, triple) and some element types (e.g. string)
Contained values are called members; element is also sometimes used. Contained values are called items; elements is also sometimes used.