Structure and interpretation of computer programs (from 100 to end)

Now we can give a new definition of scale-list in terms of map:
(define (scale-list items factor)
(map (lambda (x) (* x factor))
is an important construct, not only because it captures a common pattern, but because it
Establishes a higher level of abstraction in dealing with lists. In the original definition of
Scale-list, the recursive structure of the program draws attention to the element-by-element
Processing of the list. Defining scale-list in terms of map suppresses that level of detail and
Emphasizes that scaling transforms a list of elements to a list of results. The difference between
The two definitions is not that the computer is performing a different process (it isn’t) but that
We think about the process differently. In effect, map helps establish an abstraction barrier that
Isolates the implementation of procedures that transform lists from the details of how the
Elements of the list are extracted and combined. Like the barriers shown in figure 2.1, this
Abstraction gives us the flexibility to change the low-level details of how sequences are
Implemented, while preserving the conceptual framework of operations that transform
Sequences to sequences. Section 2.2.3 expands on this use of sequences as a framework for
Organizing programs.
Exercise 2.21. The procedure square-list takes a list of numbers as argument and returns a
List of the squares of those numbers.
(square-list (list 1 2 3 4))
(1 4 9 16)
Here are two different definitions of square-list. Complete both of them by filling in the
Missing expressions:
(define (square-list items)
(if (null? items)

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

education system of great britain
Structure and interpretation of computer programs (from 100 to end)