最初のページ 戻る 次へ 最後のページ

map(巻き戻し段階)

( map square '(1 2 3) )

(cons (square 1) (map square '(2 3)) )

(cons 1 '( 4 9 ) )

'( 1 4 9 )

(define (map f x)

(cond ((null? x) nil)

(else (cons (f (car x)) (map f (cdr x)))) ))

( map square '(1 2 3) )の評価は '( 1 4 9 )