---
title: Eboard 18  Recursion basics lab
number: 18
section: eboards
held: 2017-10-04
---
CSC 151.03, Class 18:  Recursion basics lab
===========================================

_Overview_

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

### News / Etc.

* New partners.  
* Please make sure to return your computer cards to the jar.
* It appears that some of you have ignored the instructions and have
  decided that the appropriate approach to homework is to say things
  like "You solve problems 1-3 and I'll solve problem 4-5".  So, I'll
  make it easy for you: If I find out you've done that, you get a zero
  on the homework.
* Note that the graders do want to run your programs.  If they cannot
  just load the code you've provided into DrRacket, you will likely
  lose significant numbers of points.
* You did have an obligation to show your work on problem 4.  The
  following is unacceptable.
    *  I pick “there”, “was”, and “has” to check the common connections in different files. I found through the order of the high frequency words change, the results have lots of same words. For example, after the word “was”, “to”, “a” “the”, and “that” have appeared in most of the following-word. after the word “there”, “was” and “a” are most frequently appeared.
* Please discuss which switching format you and your partner will use
    * Switch every ten minutes
    * Switch midway through class
    * Switch every problem

### Upcoming Work

* No writeup for class 17.
* [Writeup for class 18](../writeups/writeup17) due Friday at 10:30 p.m.
    * Exercise 5
    * To: <csc151-03-grader@grinnell.edu>
    * Subject: CSC 151.03 Writeup 18 (YOUR NAMES)
* Reading for Friday's class: [Recursion with helper procedures](../readings/helper-recursion)
    * Should be ready tonight.
* Exam 2 prologue due Friday at 10:30 p.m.
* Exam 2 due Tuesday at 10:30 p.m..
* Exam 2 cover sheets due Wednesday at the start of class
* Exam 2 epilogue due Wednesday at 10:30 p.m.

### Extra credit (Academic/Artistic)

* Any of the many Grinnell Prize events.
* Wednesday, 5pm, Mary Beth Tinker Talk
* Nice Fish.

### Extra credit (Peer)

* RTS, Loose Lounge, Friday, 9:30 p.m.
* Fun Palaces, Saturday, 1-3, Bucksbaum Rotunda.  Come and make art.
* Open Mike Comedy, Friday, 8pm, Main Lounge.
* Neverland players lots of performances.

### Extra credit (Misc)

* Film screening and discussion: _Together_: Changing the Conversation,
  Changing the Culture.  Bear 205, Thursday, 8:00-9:15 p.m.

### Other good things

* Men's Soccer Wednesday at 4:30 vs. Cornell
* Volleyball vs. Beloit, Friday at 7:00 p.m.
* Women's Tennis vs. St. Norbert, Saturday at 9:00 a.m.
* Volleyball vs. Lake Forest, Saturday at 1:00 p.m.
* Women's Tennis vs. Ripon, Saturday at 3:00 p.m.
* Football, Saturday at 1:00 p.m.

### Exam 2 distributed

### Questions

When can we start submitting errata?
  : 8:30 a.m. tomorrow.

Lab
---

When you hit problem 4 and feel confused, type `(*)` in the interactions pane.

Your writeup is problem 5.

Please test if a list is empty with `(null? lst)`.

Debrief
-------

```
(define sum
  (lambda (lst)
    (display (list 'sum lst)) (newline)
    (if (null? lst)
        0
        (+ (car lst) (sum (cdr lst))))))

(define my-length
  (lambda (lst)
    ; (display (list 'my-length lst)) (newline)
    (if (null? lst)
        0
        (+ 1 (my-length (cdr lst))))))
        
(define largest0
  (lambda (lst)
    ; (display (list 'largest0 lst)) (newline)
    (if (= (my-length lst) 1)
        (car lst)
        (max (car lst) (largest0 (cdr lst))))))
; Don't ask if the length of a list is 1 with (= (length lst) 1).
; Instead, use (null? (cdr lst))

; For those who want to think a bit more: How many calls to
; `largest1` will we get if the input list is `(5 4 3 2 1)`?
; How about if the input list is `(1 2 3 4 5)`?
(define largest1
  (lambda (lst)
    ; (display (list 'largest1 lst)) (newline)
    (if (null? (cdr lst))
        (car lst)
        (if (> (car lst) (largest1 (cdr lst)))
            (car lst)
            (largest1 (cdr lst))))))
```
