CSCI 301 L00 Notes

Lecture 0 - Notes

Outcomes:

Overview
Sets 0
Racket 0

Outline

Course overview and introduction / about me - 15 minutes

Get into groups!

Icebreaker / name cards - 5-10 minutes

Sets 0 - 10 minutes + 5 minutes for exercises

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:

Do Exercises Part B

Racket 0

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\).

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)