3 Define a procedure Add that takes parameters and returns t

3. Define a procedure \"Add\" that takes parameters and returns the sum of them [5 points] > (Add 40 60) 100 4. Define a procedure called \"Square\" that will compute the square amount of a value. 4.1 You must implement the Add procedure defined above 4.2 You will need to account for negative values as well Hint: This will require a conditional and possibly the (abs x) procedure [15 points] > (Square 7) 49 Define a procedure \"ReadForSquare\" to read a value for the Square procedure defined above. This procedure takes no values and will pass an input value to the Square procedure. [5 points] 5. (ReadForSquare) 25

Solution


(define (Add a b)
(+ a b) )
  
(define (abso n)
(if(negative? n)
     (- n)
     n
    )
)

    ;n^2 = (n-1)^2 - 2n -1
(define Square (lambda (n)
         
          (if (= n 0)
              0

              (Add (Square(- (abso n) 1)) (-(* 2 (abs n))1))
            
           )
               
))


(define ReadForSquare (lambda ()
(Square(read))) )

(define DiffSquares (lambda ()
                      (abso(- (ReadForSquare) (ReadForSquare)))

))

(define (AddLet a b)
(let ((a1 a)(b1 b))
   a1 b1
(+ a1 b1))
)

 3. Define a procedure \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site