Chapter 1, Building Abstractions with Procedures
Section - Procedures and the Processes They Generate
Exercise 1.17
It assumes $a,b \ge 0$.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
(define (ml a b)
(cond ((= b 0) 0)
((even? b) (double (ml a (half b))))
(else (+ a (ml a (- b 1))))
)
)
(define (half a)
(/ a 2)
)
(define (double a)
(* a 2)
)