CSC 151.01, Class 30: Other Forms of List Recursion
Overview
- Preliminaries
- Notes and news
- Upcoming work
- Extra credit
- Questions
- Lab
News / Etc.
- Continue partners
- Happy pi day!
Rotating reminders
- Use our tutors! We have tutors available Sunday through Thursday evening from 7-10 p.m. in Science 3813/15.
Upcoming Work
- HW 6 due TONIGHT!
- Lab writeup: Exercise 3. Due Friday.
- Reading for tomorrow: Numeric Recursion
- No homework over break.
- Friday’s quiz: Identify your classmates
Extra credit (Academic/Artistic)
- CS Table, Tuesday at noon, SIGCSE Debrief
- CS Extras, Thursday at 4:15 pm: ???
Extra credit (Peer)
You do not get extra credit for supporting yourself.
- Singers Concerts during spring break.
- If you go and there is an admission charge, Sam will reimburse (up to $20)
- Baseball games April 1 and 2, all day. (1 hour suffices, no more than two units for the weekend)
- Baseball games in Arkansas and Arizona during break.
Extra credit (Misc)
Good things to do
Questions
Lab
- Can we use direct recursion for exercise 1?
- Yes.
- Can we use a helper procedure and tail recursion for exercise 1?
- Yes.
- Can we use direct recursion for exercise 2?
- Yes, I’d recommend it.
- Can we use a helper procedure and tail recursion for exercise 2?
- Yes, but I think it’s harder than direct recursion.
- How many parameters to
lists-jointake? - One, a list of lists.
Writeup
Exercise 3! (It’s class 30.)
Notes for next class
-
Sam should talk about the benefit of building tables for tail-recursive procedures.
-
Sam should discuss the following code.
#lang racket
(define iota
(lambda (n)
(iota-helper 0 n)))
(define iota-helper
(lambda (start end)
(if (>= start end)
null
(cons start (iota-helper (+ start 1) end)))))
(define smallest
(lambda (lst)
(display (list 'smallest lst)) (newline)
(cond
[(null? (cdr lst))
(car lst)]
[(< (car lst) (smallest (cdr lst)))
(car lst)]
[else
(smallest (cdr lst))])))
(define minimal
(lambda (lst)
(if (null? (cdr lst))
(car lst)
(min (car lst) (minimal (cdr lst))))))
(define la
(lambda (lol)
(lala lol null)))
(define lala
(lambda (remaining so-far)
(if (null? remaining)
so-far
(lala (cdr remaining) (append so-far (car remaining))))))
(define example
(lambda (lol)
(time (la lol))
1))