sicp/zapiski/g1smo/#1_2_vaje.scm#

14 lines
281 B
Plaintext

(define (sum term a next b)
(if (> a b)
0
(+ (term a)
(sum term (next a) next b))))
(define (sum-iter term a next b)
(define (iter a result)
(if (> a b)
result
(iter (next a) (+ result (term a)))))
(iter a 0))