I have a Scheme assignment in which a user is to input a list of numbers, and the output should be the max value and min value from the list. The assignment says we can have two separate functions, and combine the result with a driver, but I don’t know how to do this. Here is what I have so far:
(define (findmin l) (if (null? (cdr l)) (car l)
(if (< (car l) (findmin (cdr l)))(car l)
(findmin (cdr l)))))
(define (findmax l) (if (null? (cdr l)) (car l)
(if (> (car l) (findmax (cdr l)))(car l)
(findmax (cdr l)))))
I can’t seem to get around having to input a list for findmin, and another list for findmax. The user should only have to input one list.
driver: