sicp-solutions/ex-1.17.scm
Petar Kapriš a697f52405 Add solutions to exercises from section 1.2
To be noted: the drawing in exercise 1.14 is unfinished. I did it in a
notebook, but haven't yet had the time to put it in a txt file.
2025-02-05 13:59:25 +01:00

10 lines
252 B
Scheme

#lang sicp
(define (double x) (* 2 x))
(define (halve x) (/ x 2))
(define (*aux a b acc)
(cond ((= b 0) acc)
((even? b) (*aux (double a) (halve b) acc))
(else (*aux a (- b 1) (+ acc a)))))
(define (fast-mul a b)
(*aux a b 0))