Geek-Side

Resource > SICP Exersise 3_1
Exersise 3.1

 (define (make-accumulator init)
   (let ((val init))
     (lambda (x) (set! val (+ val x)))))
 
 (use gauche.test)
 (test-start "Excersise 3.1")
 (define A (make-accumulator 5))
 (test* "sum1" 15 (A 10))
 (test* "sum2" 25 (A 10))
 (test-end)