Today marks a momentous occasion! We leave behind “purely” functional programming for the auspices of imperative programming. While this gives us the power to change the state of our computer (and used that changed state as parts of our programs), it also comes with increased responsibility to monitor side-effects of our programs.
Some good checks of understanding for today’s lecture!
; Why is this an exception by itself?
(set! x 5)
; Why is this okay now?
(lambda ()
"hello")
; Why is this an exception?
(define x 1)
(lambda ()
(set! x (+ x 1))
(set! x (+ x 1))
(set! x (+ x 1)))
; What type of data does this return?
(define x 1)
(define (cool-func)
(begin (set! x (+ x 1))
(set! x (+ x 1))
(set! x (+ x 1))))
(cool-func)
; What about this?
(define x 1)
(define (cool-func-1)
(begin (set! x (+ x 1))
(set! x (+ x 1))
(set! x (+ x 1)))
x)
(cool-func-1)
Today's Resources
1. Exercise Files
Download Exercise Files2. Slides
3. Pre-Recorded Lecture Video(s), Mini-Quizzes, and Live Recordings
| Link | Title | Type | Duration |
|---|---|---|---|
| Video 0 | Live Lecture Recording | lecture | 50:00 |