my attempt to do the exercises in sicp.

Monday, March 15, 2010

sicp exercise 3.34


;; Exercise 3.34.  Louis Reasoner wants to build a squarer, a constraint device with two terminals such that the value of connector b on the second terminal will always be the square of the value a on the first terminal. He proposes the following simple device made from a multiplier:

;; (define (squarer a b)
;;   (multiplier a a b))

;;   There is a serious flaw in this idea. Explain.

;; Ans:
;; In this scheme, squarer uses multiplier. multiplier needs two terminals to be specified in order to deduce the third. so to duduce the value of 'a', we need to specify 'a'.
;; Now i understand why square is a basic mathematical operation. otherwise finding square-roots would have been so easy.

No comments: