SCHEME Racket Define a procedure called Square that will com

SCHEME (Racket)

Define a procedure called “Square” that will compute the square amount of a value.

You must implement the Add procedure

You will need to account for negative values as well.

Hint: This will require a conditional and possibly the (abs x) procedure.   

> (Square 7)

49

// using addition procedure find the square of a number in Scheme

Solution

The procedure for Square(Racket)   

//Define the procedure

(define (sum-squaring lst)
(let loop ([lst lst] [acc 0]) //loop from begining


(if(empty ? lst)
acc
(abs lst)// taking absoulte value of list to avoid negative numbers
(loop rest lst) (+(*(firstval lst) (firstval lst))acc)))))   

=>please try with above snippet

SCHEME (Racket) Define a procedure called “Square” that will compute the square amount of a value. You must implement the Add procedure You will need to account

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site