This class will be recorded! Its use is limited to members of the class. Please do not share with others.
Approximate overview
Attend (or watch recording) and send a one-paragraph reflection.
I love making fun of you in the chat. I can’t imagine CS without that. Will you teach us 161 next term?
No. Weinman is awesome.
I’m a masochist and want to continue the abuse and high workload you heap on us. Will you teach us 161 next term?
See above.
Tell us about CSC-282, Thinking in C and Unix
It’s mostly designed for upper-level CS students. My experience is that there are gaps in their knowledge. This course eliminates some of those gaps.
Those who take CSC 161 in Spring 1 can register, but I expect that it will be more useful later in your career.
Tell us about CSC/PSY/TEC-232, Human-Computer Interaction
Not a programming class.
An opportunity to think/talk/read through how we build software (or other technologies) that normal people can use.
Ideally: Brings together students with different skills in projects.
I already know C/Java/everything you could ever want to teach me. Can I skip 161/207/the whole CS major?
We tend to do personal interviews to determine whether or not you should take or skip a CS course.
Will you teach us recursion?
See below.
Will you teach us recursion?
See above.
No other questions on recursion permitted. We’ll talk about it and you’ll do lab and things will get clearer.
Do you look at what the formatted eboards look like?
Not normally. I trust my awesome markdown skills.
More seriously, I trust that you’ll tell me if I’ve screwed up the formatting.
Why do you make “jokes” (scare quotes intentional) in the Q&A section?
Why not?
let expressionslet trace suggest a few issues (which may be time related).lambda does not get evaluated until it is applied.define does not get evaluated.
The define does update a table of definitions (bindings).(if TEST TRUEPART FALSEPART) : Do the TEST. Then either do
the TRUEPART or the FALSEPART.
TRUEPART when the TEST is true (#t)
FALSEPART when the TEST is false (#f).FALSEPART after we evaluate the TEST.FALSEPART.(and EXP1 EXP2 ... EXPn): Evaluate each expression until
(a) we find one that’s false or (b) we’ve evaluated all the
expressions.
and
immediately returns false (#f).#f, so it has evaluated all of them.(and #t 'um 'um (+ 4 2))
#f) [+1] (argument: 'um is false)#t)6) (argument: 'um is not false, so it’s truish) [+2](not EXP): Evaluate the expression: If it gives a truish value,
return false (#f), otherwise, return true (#t).
(- EXP)?(or EXP1 EXP2 ... EXPn): Evaluate the expressions left to right
until we get a truish, in which case we return the value. If we run
out of expressions, we get false (#f).
* (or #f (< 4 2))
* 'um [+1]
* #f
* (or #f (+ 4 2))
* 6 [+1.5] The winner
* #t [+0.5]
* “Love is the answer” The conceptual winner
* (or)
* False (#f) [+2]
* Something empty (e.g., the empty list)
* Error: “or expects at least one parameter”(cond [GUARD1 EXP1a EXP1b ... EXP1x] [GUARD2 EXP2a EXP2b ... EXP2x] [ELSE ALTa ... ALTx])
cond has those weird boxed things.else, it just does the expressions in the
else box.(cond ["hello" 1] [else "zebra"]) --> 1(cond [is-the-world-round "yay"] [else "what world?")cond have multiple expressions?
cond is the value of the last expression
in the sequence corresponding to the first guard that holds.(let* ([NAME1 EXP1] [NAME2 EXP2] ... [NAMEn EXPn]) BODY)(let ([NAME1 EXP1] [NAME2 EXP2] ... [NAMEn EXPn]) BODY)(o PROC1 PROC2 ... PROCn)(section PROC PARAM <>) (and variants)> (define something
(lambda (x)
(cond
[(odd? x)
1
2
3]
[(>= x 10)
"hello"
"goodbye"]
[(= x 6)]
[(* x 3)]
[else
"zebra"])))
> (something 5)
; Proposal 1: 1 2 3 [+1]
; Proposal 2: An error message [+2]
3
; Why? 3 is the last of the expressions
> (something 12)
; Proposal 1: "goodbye" [+1]
; Proposal 2: "hello"
; Proposal 3: "You say goodbye, I say hello. Hello hello."
"goodbye"
> (something 8) ; before we inserted the (* x 3)
; Proposal 1: "zebra" [+1]
; Proposal 2: "A horse of a different color"
"zebra"
> (something 6)
; Proposal 1: 'um [+1]
; Proposal 2: Nothing aka `#void`
; Proposal 3: Error
; Proposal 4: True (`#t`)
#t
> (something -4)
; Proposal 1: "Freudian slip"
; Proposal 2: 'um
; Proposal 3: "Zebra" [+2]
; Proposal 4: -12 [+2] -10
; Proposal 5: True (`#t`)
; Proposal 6: Error
-12
> (define x 2)
> (cond [> x 3 "hello"] [else "something else"])
; Proposal 1: Error [+2]
; Proposal 2: True (`#t`)
; Proposal 3: "hello"
; Note: No parens, doesn't apply the procedure
"hello"
; Note: Forgetting things in conds can give you really weird values.
> (symbol? 'um)
#t
> (symbol? '())
#f
> (symbol? '23)
#f
> (symbol? 'our-mentors-are-plants)
#t
Can you please give us a quiz on tracing tomorrow?
Maybe
When is the next mini-project going to be released? What is going to be like?
Hopefully less than #3. Tell me when it’s not.
What is “the normal model”?
The initial model.
“Evaluate all the paremeters before applying the procedure.”
How to evaluate the application of a lambda expression.
(define fred
(lambda (x)
(+ (/ 1 x) (* x x))))
; (fred (- 5 3))
; --> (fred 2)
; --> (+ (/ 1 2) (* 2 2))
; --> (+ 1/2 (* 2 2))
; --> (+ 1/2 4)
; --> 9/2 (or 4 1/2)
(define derf
(lambda (x)
(or (/ 1 x) (* x x))))
; (derf (- 5 3))
; --> (derf 2)
; --> (or (/ 1 2) (* 2 2))
; --> (or 1/2 (* 2 2))
; ; Note: We do not do the 2*2
; --> 1/2
(define name
(lambda (x)
(+ (* x x) (/ 1 x))))
; (name 0)
; --> (+ (* 0 0) (/ 1 0))
; --> (+ 0 (/ 1 0))
; --> boom! Illegal division
(define eman
(lambda (x)
(or (* x x) (/ 1 x))))
; (eman 0)
; --> (or (* x x) (/ 1 x))
; --> (or 0 (/ 1 0))
; --> 0
“What a great idea for a quiz.”