Approximate overview
Thank you to those of you who filled out the survey!
For partnering: There were more ‘ehs than I’d like. (Okay, any ‘ehs is more than I’d like, but we had about 25% ‘ehs.)
You should see their comments. (Note that there are also positive comments.)
In your own words, explain what each kinds of strings each of the following regular expressions describes.
(define r1
(rex-concat (rex-string "\"")
(rex-char-antiset "\"")
(rex-string "\"")))
(define r2
(rex-any-of (rex-char-range #\a #\z)
(rex-char-range #\A #\Z)
(rex-char-set "'-")))
(define r3
(rex-repeat r2))
(define r4
(rex-concat (rex-char-range #\A #\Z)
(rex-repeat (rex-concat r3 (rex-string " ")))
(rex-string "love ")
(rex-repeat (rex-concat r3 (rex-string " ")))
(rex-char-set ".?!")))
Write a procedure, (rex-tally rex str), that counts how many times that
the pattern given by rex appears in string.
> (rex-tally (rex-string "a") "alphonse says albert and fatima are alphabetical")
10
> (rex-tally (rex-string "al") "alphonse says albert and fatima are alphabetical")
4
> (rex-tally (rex-char-set "aeiou") "alphonse says albert and fatima are alphabetical")
17
> (rex-tally (rex-concat (rex-string "a")
(rex-char-antiset "a")
(rex-string "a"))
"alphonse says albert and fatima are alphabetical")
1
> (rex-find-matches (rex-concat (rex-string "a")
(rex-char-antiset "a")
(rex-string "a"))
"alphonse says albert and fatima are alphabetical")
'("a a")
Write a regular expression that matches the common form of “words” in English. Words start with a lowercase or uppercase letter and then have a sequence of lowercase letters, apostrophes, and dashes.
None today.
Can you go over tracing of recursive procedures?
It should be the same as tracing of any other procedure. However, we tend to skip a few steps.
But what you’ll often observe is that we build up a lot of delayed computations that only get done when we reach the base case.
And you’ll get some practice in lab.
Why is cdr pronounced “could-er”?
It’s hard to pronounce things with no vowels. I suppose “code-er” would be funnier.
Between the “big three” list functions and recursive list function, which is more efficient/concise? Are there any special cases where we should use one over the other?
There are so many contextual issues that it’s hard to answer your question. It’s nice to think in terms of the “big three” list functions. But as we’ll see, the “big three” are often implemented with recursion. I tend to prefer that you use the big three, except when you’re learning how to write recursive procedures.
Note: You’ll learn how to write the big three in class. One of the outcomes of this class should be that you can write most of the procedures you use (except for some really basic ones, like
+orcons).
What’s going on with (awesum (list 5 2))?
(define awesum
(lambda (lst)
(if (null? lst)
0
(+ (car lst) (awesum lst)))))
(awesum (list 5 2))
; The list is not null
--> (+ 5 (awesum (list 5 2)))
; The list is not null
--> (+ 5 (+ 5 (awesum (list 5 2))))
; The list is not null
--> (+ 5 (+ 5 (+ 5 (awesum (list 5 2)))))
; The list is not null
--> ...
It keeps expanding forever because we never make the input “smaller”.
What does (awesum (list 5 2)) really result in?
It runs forever, so there is no final result.
Can you use car and cdr outside of recursion?
Yup. Anywhere you have a list you can use
carandcdr.
Can you use procedures other than car and cdr in recursion?
Yes, as long as they simplify the parameters.
takeanddropare a nice pair.
Can two procedures each refer to each other?
Yes. We often call that “mutual recursion”.
Can we use Zen of Booleans ideas in recursion?
Yes.
Do we have to?
Walk before your run. First get competent with recursion, then worry about doing it elegantly.
Do I still have to complete a lab if I missed class?
Definitely! How else will you learn the material?
I’m worried that I’m falling behind. What should I do?
Chill. Different people learn at different rates.
Talk to Sam or the mentors, depending on who you are more comfortable with.
Ask for an individual tutor to help you through things.
Could you not cold call me? It makes me too nervous.
Certainly. Chat with me and I’ll put a mark on your card. But you do need to volunteer.
Can I have SamR’s approval to __?
Talk to me.
Can we get better keyboards? These are really flimsy.
That’s out of my control. Sorry.
I don’t like working in pairs. Can I work alone?
Nope. You should develop skills working with others.
Can you change the due date for quizzes to Sunday?
Sure. But I’ll probably make them due before the mentor session.
Why do we use three commas for documentation?
It’s common practice that lets us distinguish documentation from other comments.
We can then do fun things like the following.
(define doc
(rex-concat (rex-string ";;; ")
(rex-repeat (rex-any-char))))
(define extract-doc
(lambda (fname)
(filter (section rex-matches? doc <>)
(file->lines fname))))
What happens if I forgot to do something required?
Ask Sam to spend a token for a lab or reading writeup.
Wait until the SoLA for a quiz.
Wait until the next SoLA for a SoLA.
Spend tokens for the “redo” for an MP.
If I get the quiz right but the corresponding SoLA wrong, what happens?
Look at the grade sheet. If it’s checked off, you are fine.
How do I resubmit the decomposition SoLA that’s due tonight?
Email or DM me. You can also enter the answer as a comment under “Request Regrade”.
Please take the time to chat with your partner. You may want to re-review some of the concerns.
Make sure that exercise 1 begins with func-1a and not func-1.
(*) is 1 and (+) is 0."; SAM SAID I COULD STOP HERE" so that the grader does
not attempt to look at more.