University of Washington • CSE583 • D. Notkin
©
2000
28
Recursion over lists
l
Lists are a recursive
data type
–
A list is either
()
[base
case]
–
Or a pair of a value
and another list
[inductive case]
l
Good for
manipulation by
recursive functions
that share this
structure
l
(define (f x …)
l
(if (null? x)
l
…base case
l
…inductive case
l
on (car x)
with recursive
call (f (cdr x))
l
))