In section 1.3 of SICP, we are abstracting the summation process by introducing two procedures as arguments for the procedure.
(define (sum term a next b)
(if (> a b) 0
(+ (term a) (sum term (next a) next b))))
Why can't we write the same procedure like this:
(define (identity a ) a)
(define (next a) (+ a 1)
(define (sum a b)
(if (> a b) 0
(+ (identity a) (sum (next a) b))))
I am not able to understand the reason for passing procedures as arguments in this particular example.
Is there any special reason for that? Or is it just for the purpose of demonstrating the concept?
Is there a better example?