Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. Define a procedure \"Add\" that takes parameters and returns the sum of them

ID: 3935753 • Letter: 3

Question

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

Explanation / Answer


(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))
)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote