---
title: Eboard 32  Analyzing procedures
number: 32
section: eboards
held: 2017-11-13
---
CSC 151.01, Class 32:  Analyzing procedures
===========================================

_Overview_

* Preliminaries
    * Notes and news
    * Upcoming work
    * Extra credit
    * Questions
* Lab
* Debrief

### News / Etc.

* We finally get to analyzing procedures today.  Sorry for the delay.
* Please try to keep the room straight.  
* Exam 2 returned last night.  If you didn't get it, let me know.
* Quiz 11 returned.  Some issues on `l-s` vs. `r-s`

### Upcoming Work

* Reading for Wednesday: [Association lists](../readings/association-lists)
    * Since it was ready for today, it's still ready for Wednesday.
* No writeup for class 31.
* [Writeup for class 32](../writeups/writeup32) due Wednesday at 10:30 p.m.
    * Exercise 6
    * To: <csc151-01-grader@grinnell.edu>
    * Subject: CSC 151.01 Writeup 32 (YOUR NAMES)
* [Exam 3](../exams/exam03) 
    * Exam due TOMORROW
    * Cover pages due Wednesday the 15th.
    * Epilogues due Wednesday the 15th.

### Extra credit (Academic/Artistic)

* Convocation Thursday at 11 a.m. in JRC 101.  "Work's Provocative Future: 
  Which Graduates Will Thrive?"

### Extra credit (Peer)

* "The First Time I Walked on the Moon".  Five, count 'em, five performances.
  Th7:30 F7:30 S2, S7:30 Sun2:00 Flanagan Theatres
* Orchestra, Satruday at 2pm

### Extra credit (Misc)

### Other good things

* Fresh Flutes Thursday
* Voice recitals Friday at 4:15 (Henderson) and 7:00 (Manuel)
* Women's Basketball vs. Emmaus Wed at 5:00 p.m.
* Men's Basketball vs. Emmaus Wed at 7:00 p.m.
* Swimming and Diving Saturday at 1:00 p.m.

### Questions

Could you help me understand the difference between left-section and right-section?
  : Sure.
  : Left section and right section both fill in one parameter to a
    two parameter procedure, leaving you with a one-parameter procedure.
  : Left section fills in the left parameter.
  : Right section fills in the right parameter.
  ; `(l-s fun x)` == `(section fun x <>)`
  ; `(r-s fun x)` == `(section fun <> x)`
  : If I want a procedure that divides by 2, the 2 should be on the
    right, and I want `(r-s / 2)`.
  : If I want a procedure that divides by n, the n should be on the
    right, and I want `(r-s / n)`.

I'm having trouble with problem 4.  Is there a pattern that will help?  And can you help me understand that pattern?
  : Sure.

```
;;; Procedure:
;;;   number-vector-increment!
;;; Parameters:
;;;   vec, a vector
;;; Purpose:
;;;   Increment the value at all vector positions
;;; Produces:
;;;   [Nothing; called for side effect.]
;;; Preconditions:
;;;   (vector-ref vec index) for 0 <= index < (vector-length vec) is a number.
;;;   number-vect-increment-at! is defined
;;; Postconditions:
;;;   Let val be (vector-ref vec index) before the procedure call. After the
;;    call (vector-ref vec index) produces val+1.
(define number-vector-increment!
  (lambda (vec)
    (let ([len (vector-length vec)]) ; unchanging value, tells recursion to stop
      (let kernel! ([pos 0])  ; Start the recursion at the first position
        (when (< pos len) ; When the position is valid,
          (number-vector-increment-at! vec pos) ; increment the number at pos
          (kernel! (+ 1 pos))))))) ; and process the rest of the vector

```

Note that `number-vector-increment-at!` does a `vector-ref` and a
`vector-set!`.  I expect you'll want to do something similar.

Do we have to return the vector for problem 4?
  : I would prefer that you *not* return the vector.
  : But if you choose to return the vector, you will not lose points
    for doing so.

Lab
---

What do you mean by "total calls"?
  : Include the counts for `car`, `cdr`, `cons`, `null?` and such.

Why is `list-reverse-1` so much worse?
  : That's one of those things the lab is intended to get you to think about.
  : But it's because we're calling `list-append` repeatedly, and 
    `list-append` needs to recurse through the first list.

What is the writeup?
  : Exercise 6

Debrief
-------

I know it's not part of this lab, but can we go over the tree recursion problem from the quiz?
  : Sure, if there's time.
