2.21

1 ]=>(define nil (list))

;Value: nil

1 ]=> (define (square x) (* x x))

;Value: square

1 ]=> (define (square-list items)
(
if (null? items)
nil
(cons (square (car items))
(square
-list (cdr items)))))

;Value: square
-list

1 ]=> (square-list (list 1 2 3 4))

;Value
11: (1 4 9 16)

1 ]=> (define (square-list items)
(map square items))

;Value: square
-list

1 ]=> (square-list (list 1 2 3 4))

;Value
12: (1 4 9 16)

 

posted @ 2011-01-19 00:13  penink  阅读(202)  评论(0编辑  收藏  举报