EBoard 31: Searching and Analysis

This class will be recorded! Its use is limited to members of the class. Please do not share with others.

Approximate overview

  • Administrative stuff [~10 min]
  • Notes from SoLA 3 [~10 min]
  • Q&A [~10 min]
  • Lab [~60 min]

Administrative stuff

Notes and News

  • Some notes on the coming week.
  • Class attendance is expected/required Thursday.
  • Class attendance is definitely expected/required Friday. (Yay! You get to evaluate me.)
  • Today’s obligatory joke, inspired by the assignment and your responses. “ghoti”
  • Does anyone not understand the “Time flies like an arrow; fruit flies like an apple” pairing?
    • In the first sentence, flies is a verb; in the second, flies is a noun.
    • In the first sentence, the thing before “Flies” is a noun; in the second, it serves as an adjective (it’s a noun serving as an adjective)
    • In the second sentence, “like” is the verb. In the first sentence, “like” introduces an adverbial phrase.
  • Tomorrow’s class will end at 3:55 p.m. We’ll continue the discussion on Wednesday.

Upcoming activities and other token-earning things

Events

  • Tuesday, Community Circles.
  • Wednesday, Mentor Session at 7pm.

Upcoming work

I’m not sure if all of these links are correct. Let me know if any are not.

  • No reading for Tuesday! Only one more reading response to go.
  • Lab writeup
  • Mini-project 6 due TONIGHT!
    • Our last mini-project!
  • Mini-project makeups
    • Due March 24 at 11:59 p.m.
  • SoLA 4 Thursday
    • Starts at 3:30pm Thursday.
    • 48 hours, until 3:30pm Saturday
    • The sooner you do it, the sooner you’ll get grades back.

Some notes from SoLA 3

Tail recursion

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)))

Style!

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.)

More style!

;;; (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))))

Q&A

Administrative

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.

MP6

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.

SoLAs

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.

Other

Do you think that today’s Teams chaos is a sign?

Yes.

Take today to work on your MP6.

Lab