This class will be recorded! Its use is limited to members of the class. Please do not share with others.
Approximate overview
I will demo each. (Or at least I hope I will demo; computers have not been my friends of late. And there’s that date thing.)
Attend (or watch recording) and send a one-paragraph reflection.
Things that categorized (or we hope will categorize) E-level work on mini-project 1.
If you redo MP 1, make sure to stick to things you knew at the time of MP 1 (unless you are one of the few who Bingled more advanced solutions).
We’ll work on making sure there are more detailed comments on the next mini-project to help you achieve E in your redo.
How do we ask questions about our grading?
Chat Sam on Teams.
reduce
? It seems unpredictable.Basic idea: Combine neighboring pairs using a procedure until you have a single value.
(reduce + (list 4 1 2 3 6 4 7))
---> (reduce + (list 4 1 5 6 4 7))
---> (reduce + (list 4 1 5 6 11))
---> (reduce + (list 5 5 6 11))
---> (reduce + (list 5 11 11))
---> (reduce + (list 5 22))
---> (reduce + (list 27))
---> 27
We’ve made it unpredictable to model what happens with
reduce
in the real world.
If you want predictable,
reduce-left
andreduce-right
.
Or you should choose an operation in which the order doesn’t matter.
We sometimes need to escape impurity.
let
vs. let*
Today’s lab will explain.
See today’s lab.
(define years-to-seconds-b
(let* ([days-per-year 365.24]
[hours-per-day 24]
[minutes-per-hour 60]
[seconds-per-minute 60]
[seconds-per-year (* days-per-year hours-per-day
minutes-per-hour seconds-per-minute)])
(lambda (years)
(* years seconds-per-year))))
--> (define years-to-seconds-b
(let* ([hours-per-day 24]
[minutes-per-hour 60]
[seconds-per-minute 60]
[seconds-per-year (* 365.24 hours-per-day
minutes-per-hour seconds-per-minute)])
(lambda (years)
(* years seconds-per-year))))
--> (define years-to-seconds-b
(let* ([minutes-per-hour 60]
[seconds-per-minute 60]
[seconds-per-year (* 365.24 24
minutes-per-hour seconds-per-minute)])
(lambda (years)
(* years seconds-per-year))))
--> (define years-to-seconds-b
(let* ([seconds-per-minute 60]
[seconds-per-year (* 365.24 24
60 seconds-per-minute)])
(lambda (years)
(* years seconds-per-year))))
--> (define years-to-seconds-b
(let* ([seconds-per-year (* 365.24 24
60 60)])
(lambda (years)
(* years seconds-per-year))))
--> (define years-to-seconds-b
(let* ([seconds-per-year 31556736.0])
(lambda (years)
(* years seconds-per-year))))
--> (define years-to-seconds-b
(lambda (years)
(* years 31556736.0)))
Lab —