some solutions for MIT Press's "structure and interpretation of computer programs", I guess
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
269 B

(define (double x)
(+ x x))
(define (halve x)
(/ x 2))
(define (nice-mult a b)
(define (iter acc a b)
(cond ((zero? b) acc)
((even? b) (iter acc (double a) (halve b)))
(else (iter (+ acc a) (double a) (halve (- b 1))))))
(iter 0 a b))