Warning! You are being recorded (and transcribed).
Approximate overview
Academic/Scholarly
Cultural
Peer
Wellness
Misc
Do we have to be in a group for Project 9?
No. The amount of work expected on the final project is proportional (more or less) to the number of people in the group.
We’ll talk more about that on Wednesda.
Where does the term “kernel” come from?
My colleague, John Stone, seems to have coined it as part of a broader Iowan “husk and kernel” programming strategy. The husk protects the kernel. The kernel is where the real value happens.
Is there a situation where you could have multiple accumulator variables?
Certainly. The split procedure that you worked on in the last lab is one such example.
What is letrec?
letrecis just likelet, but is necessary when you define recursive procedures.
As you may recall,
(let ([name exp]) ...), evaluatesexpand then binds it toname. For a recursive procedure,expwill includename. Butnamemay not be bound yet.letrecdoes something a bit more complicated to accommodate this situation.
Sam’s stupid demo.
(define fun
(lambda (x)
"happy happy joy joy"))
(define hssc
(lambda (x)
(let ([fun (lambda (x)
(if (zero? x)
"done"
(string-append "something " (fun (- x 1)))))])
(fun x))))
(define husk
(lambda (x)
(letrec ([fun (lambda (x)
(if (zero? x)
"done"
(string-append "something " (fun (- x 1)))))])
(fun x))))
[Sam told an amazing shaggy dog story leading up to “unbounded fun.]
When using a tail-recursive kernel with an extra so-far parameter,
can you make decisions on how you change so-far at each step?
Certainly. You can do whatever you want within the recursive call (as long as you avoid infinite recursion).
Which of the following do you prefer (for the original)?
(define tally-symbols
(lambda (lst)
(if (null? lst)
0
(if (symbol? (car lst))
(+ 1 (tally-symbols (cdr lst)))
(tally-symbols (cdr lst))))))
or
(define tally-symbols
(lambda (lst)
(cond
[(null? lst)
0]
[(symbol? (car lst))
(+ 1 (tally-symbols (cdr lst)))]
[else
(tally-symbols (cdr lst))])))