SICP exercise 2.21

From Drewiki

Jump to: navigation, search

Problem

The procedure square-list takes a list of numbers as argument and returns a list of the squares of those numbers.

 

Output:

(1 4 9 16)


Here are two different definitions of square-list. Complete both of them by filling in the missing expressions:

 

Solution

Here's the complete first definition, plus the definition of square from our previous exercises:

 

Test:

 

Output:

(1 4 9 16)


And now the complete second definition:

 

Test:

 

Output:

(1 4 9 16)
Personal tools