最初のページ 戻る 次へ 最後のページ 図
(reduce + '(1 2 3) 0)
(reduce + '(1 2 3) 0)
⇒(+ 1 (reduce + '(2 3) 0))
⇒(+ 1 (+ 2 (reduce + '(3) 0)))
⇒(+ 1 (+ 2 (+ 3 (reduce + '() 0))))
⇒(+ 1 (+ 2 (+ 3 0)))
⇒(+ 1 (+ 2 3))
⇒(+ 1 5)
⇒6
xは空リストではない
(f (car x) (reduce f (cdr x) v))
xは空リスト
(reduce + '())は0