CSC151.02 2003F, Class 38: Higher-Order Procedures, Concluded (Temporarily)
Admin
* Revamped schedule. Project dropped (probably).
* Monday: Discuss exam
* Reading (for Tuesday): Variable-Arity procedures
* Lab writeup also due Tuesday
Overview:
* Work on the lab.
* Reflect.
Remember: Named Let is a "cool shorthand" for "define and call recursive
procedure"
(define sum
(lambda (lst)
(letrec ((kernel (lambda (remaining tmp)
(if (null? remaining)
tmp
(kernel (cdr remaining) (+ tmp (car remaining)))))))
(kernel lst 0))))
Here's another, very similar, version
(define sum
(lambda (lst)
(letrec ((kernel (lambda (remaining tmp)
(if (null? remaining)
tmp
(kernel (cdr remaining) (+ tmp (car remaining)))))))
(kernel (cdr lst) (car lst)))))