Chapter 2, Building Abstractions with Data
Section - 2.2 - Hierarchical Data and the Closure Property
Exercise 2.23
1
2
3
4
5
6
7
8
9
10
11
#lang sicp
(define (for-each proc l)
(cond
((null? l) true)
(else
(proc (car l))
(for-each proc (cdr l))
)
)
)
Note that here, cond
is used instead of if
because in “else” part it is required to execute two statements. This cant be done
using if
.