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

14 lines
281 B
Plaintext
Raw Normal View History

2024-05-29 21:56:50 +02:00
(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))