Below is a question Im having issues with what I have so far will be after the ?
ID: 3663811 • Letter: B
Question
Below is a question Im having issues with what I have so far will be after the ?
Dont know y but it doesnt work...
17.5 Here's a procedure that takes two numbers as arguments and returns whichever number is larger:
Use max2 to implement max, a procedure that takes one or more numeric arguments and returns the largest of them.
; Here's a procedure that takes two numbers as arguments and returns whichever
; number is larger:
;
; (define (max2 a b)
; (if (> b a) b a))
;
; Use max2 to implement max, a procedure that takes one or more numeric arguments
; and returns the largest of them.
(define (max2 a b)
(if (> b a) b a))
(define (maxxx n . the-rest)
(if (null? the-rest)
n
(apply maxxx
(cons (max2 n (car the-rest))
(cdr the-rest)))))
Explanation / Answer
the problem is with the parenthesis kindly make the following changes and execute it:
(define (max2 a b)
(if ((> b a)) b a))
(define (maxxx n . the-rest)
(if (null? the-rest))
n
(apply maxxx
(cons (max2 n (car the-rest))
(cdr the-rest)))
:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.