Warning! You are being recorded and transcribed, provided the technology is working correctly.
We are back to the standard start-of-class procedure.
Approximate optimistic overview
Scholarly
Artistic
Multicultural
Peer
Musical, theatric, sporting, and academic events involving this section’s students are welcome.
Wellness
Misc
These do not earn tokens, but are worth your consideration.
When will we get grades on today’s quizzes?
Sam hopes to have those done tonight.
What should we submit for redos?
The updated
.rkt
file.
Any images required by the assignment.
A text (preferably) or PDF file name
CHANGES.txt
(orCHANGES.pdf
) that summarizes what problems you had the first time and what changes you’ve made. It can also beCHANGES.rkt
.
I accidentally opened an LA early because I didn’t understand the timing. Can you help me?
Yes, I can reset them if you DM me.
Why does the equality predicate =
not also count as a comparator?
Comparators are supposed to tell you whether one thing comes before another.
=
does not.
Could you go over the not
procedure and its uses?
(not expression)
-> Gives the “opposite” result of the expression.
;;; (anything-but-string? val) -> boolean?
;;; val : any?
;;; Returns false if `val` is a string and true otherwise.
(define anything-but-string?
(lambda (val)
(not (string? val))))
I read and reread the truish breakdown and was still confused. What are examples of statements that would result in a truish output? What would produce not false, but then not be true?
(not #f)
is always true,#t
.
However, there are values that are neither
#f
nor#t
. For example,"hello"
or the result of(+ 2 3)
. We consider those “truish”. If we use them as the test/guard in a conditional, instead of an error, we’ll see them treated as if they were true.
What do we need to understand when making the distinction between keywords and procedures?
You should understand that the order of evaluation is different (and, preferably, what that order is).
Normal (e.g.,
(+ exp1 exp2 exp3)
,exp1
is(* 3 4)
): Evaluate each expression from left to right and then add them. (In general, evaluate from left to right and then apply the procedure.)
Lambda (i.e.,
(lambda (params) exp)
): When we apply one of these, we substitute the arguments for the corresponding parameters in the expression and then evaluate the updated expression. What about just the lambda? It builds a procedure, but does NOT evaluate the expression until later. (It also doesn’t evaluate the params.)
If (i.e.,
(if test consequent alternate)
): Evaluate thetest
. If it’s true, evaluate the consequent and return its value. If the test evaluated to false, evaluate the alternate and return its value.
And (i.e.,
(and exp1 exp2 exp3)
): Evaluates the expressions one by one. If any of them are false, immediately returns false and does not evaluate the remaining expressions. If none of them are false (it has evaluated all of them), return the value of the last expression.(and (string? s1) (string? s2) (string-append s1 s2))
.
Or (ie..,
(or exp1 exp2 exp3)
): Evaluates the expressions one at a time. If any of them are truish, returns that value. If all of them are false, returns false.
A hint for median-of-three
(cond
[(<= x y z)
?]
[(<= y z x)
?
...
])