Get into groups!
Icebreaker / name cards - 5-10 minutes
A set is an unordered collection of unique items. The items in a set are its elements.
This membership relationship is denoted \(a \in S\), read “\(a\) is an element of \(S\).”, or “\(a\) is in \(S\).” If \(a\) is not in \(S\), we write \(a \not\in S\).
You can write a set by listing its elements in curly braces (this is the “roster method”):
For example: If \(S = \{1, 2, 3, 4\}\), then \(1 \in S\) and \(2 \in S\), but \(0 \not\in S\).
Sets are unordered: changing the order you list the elements does not change the set:
\(S = \{2, 3, 4, 1\} = \{1, 2, 3, 4\}\), and so on.
Elements of a set must be unique: listing an element more than once does not change the set:
\(S = \{1, 2, 3, 4\} = \{1, 1, 2, 3, 4, 4\}\), and so on.
If the meaning is obvious, you can use ellipses (\(\ldots\)) to describe a set without listing all of its members:
\(A = \{\text{a}, \text{b}, \text{c}, \ldots, \text{z}\}\) describes the English alphabet.
Do Exercises Part A
Sets Important Enough to Have a Dedicated Symbol:
\(\mathbb{N}\) is the set of natural numbers \(\{1, 2, 3, \ldots\}\)
\(\mathbb{Z}\) is the set of integers \(\{\ldots, -2, -1, 0, 1, 2, \ldots\}\)
\(\mathbb{Q}\) is the set of rational numbers, i.e., numbers that can be written as a fraction \(a/b\) where \(a, b \in \mathbb{Z}\) and \(b \ne 0\).
\(\mathbb{R}\) is the set of real numbers; \(\mathbb{C}\) is the set of complex numbers.
\(\varnothing\) is the empty set, i.e., the set containing no elements. It can also be written \(\{\}\), or \(\emptyset\).
Do Exercises Part B
Functions (methods, operators, procedures, etc. etc.) are core to programming - even more so than you may have recognized!
Consider applying a function/operator (say, addition) to two arguments \(a\) and \(b\).
Math: \(a + b\)
Most programming languages: add(a, b)
Lisp and its relatives: (+ a b)
, or
(add a b)
This is called prefix notation - where the operator (or function) appears before its arguments.
Let’s play in DrRacket:
+ 2 3)
(* 1 6)
(/ 2 0) ; hope this throws an error! btw, comments start with ;
(max 9 7) ; racket has a bunch of builtin functions
(max 9 7 12) ; there might be occasional benefits to this prefix notation thing...
(
integer? 12) ; booleans look like #t and #f
(number? 12) ; predicates (functions that return a boolean) traditionally end in ?
(string? 12)
(string? "abc")
(boolean? #f) (