This class will be recorded! Its use is limited to members of the class. Please do not share with others.
Approximate overview
Events
I’m not sure if all of these links are correct. Let me know if any are not.
Some of you seem inclined to use append to build lists in your tail
recursive procedures. Using append likely obviates any benefit
you may get from tail recursion. Remember: append is expensive.
(define insert-between-helper
(lambda (val lst so-far)
(cond
[(null? lst)
so-far]
[(null? (cdr lst))
(append so-far lst)]
[else
(between-helper val
(cdr lst)
(append so-far
(list val)
(list (cadr lst)))))))
(define insert-between
(lambda (val lst)
(insert-between-helper val lst null)))
Here’s a sample solution to vector-tally.
(define vector-tally
(lambda (vec pred?)
(letrec ([helper (lambda (vec pred? so-far pos)
(cond [(equal? (vector-length vec) pos)
so-far]
[(equal? #t (pred? (vector-ref vec pos)))
(+ 1 (helper vec pred? so-far (+ 1 pos)))]
[(equal? #t (not (pred? (vector-ref vec pos))))
(helper vec pred? so-far (+ 1 pos))]))])
(helper vec prec? 0 0))))
There are at least five things that bother me about this otherwise-correct code. Can you tell what they are? (And yes, I realize that good style is not at the top of your mind when you do SoLAs.)
;;; (la2let n) -> string?
;;; n : integer?
;;; Convert a count of LAs to a letter grade.
(define la2let
(lambda (n)
(cond [(< n 21)
"Other"]
[(and (>= n 21)
(< n 24))
"C"]
[(and (>= n 24)
(< n 27))
"B"]
[(and (>= n 27)
(<= n 28))
"A"])))
;;; (hash-increment! hash key) -> void?
;;; hash : hash?
;;; key : string?
(define hash-increment!
(lambda (hash grade)
(hash-set! hash grade (increment (hash-ref hash grade 0)))))
;;; (record-grades! grades list-of-la-counts) -> (void?)
;;; grades : hash?
;;; list-of-la-counts : listof integer?
;;; See problem for specs.
(define record-grades!
(lambda (grades list-of-la-counts)
(let [(letter-grades (map (section la2let <>) list-of-la-counts))]
(map (section hash-increment! grades <>) letter-grades))))
When will the mini-project redos be graded?
I’ll check with the graders.
I will try to catch up when I can catch up.
Do the sentence ends in MP6 have to be in order?
No. As long as it’s the right words, any order is fine. But if you use regular expressions to find them, you’re likely to find them in the same order.
Will you set up a place to submit mini-project 6?
Yes. Soon.
How many LAs on Thursday?
6 plus the special bonus
What about LAs that depend on today’s class.
Um … Sam is rethinking LAs right now.
What is SoLA 5?
SoLA 5 is the “final”. It contains no new topics, but gives everyone one last chance on any of the LAs they missed on SoLAs 1-4.
When does SoLA 5 open?
Some time Monday of finals week.
Do you think that today’s Teams chaos is a sign?
Yes.
Take today to work on your MP6.