Chat (Lingr.com)
Informaiton
Daily
Column
- MySQL日本語の旅(5/1)
- アクセス向上秘伝(5/9)
- 一風変ったHaskellλ門(6/13)
- SICP Answer Book (5/31) 問題3.26追加
Zope Solution
Extra
アーカイブ
OSS案内所
Site Info
関連リンク
##(link2sicp "book-Z-H-12.html#%_thm_1.32" "Exercise 1.32")
解答例
sum と product
(define (sum term a next b) (accumulate + 0 term a next b)) (define (product term a next b) (accumulate * 1 term a next b))
再帰プロセス版 accumulate
(define (accumulate combiner null-value term a next b)
(if (> a b)
null-value
(combiner (term a)
(accumulate combiner null-value term (next a) next b))))
反復プロセス版 accumulate
(define (accumulate combiner null-value term a next b)
(if (> a b)
null-value
(accumulate combiner (combiner null-value (term a)) term (next a) next b)))
コード
##(sicp-answer-code "ex-1.32.scm")