我需要找到一个列表的最大值和最小值,然后添加一个新列表。到目前为止,这是我的代码:
(define alist '(18 39 57 -4 0)
(define (nMax alist)
(if (null? (cdr alist))
(car alist)
(if (> (car alist) (nMax (cdr alist)))
(car alist)
(nMax (cdr alist)))))
(define (nMin alist)
(if (null? (cdr alist))
(car alist)
(if (< (car alist) (nMin (cdr alist)))
(car alist)
(nMin (cdr alist)))))
现在我被困住了。如何在新列表中添加nMin
+ ?nMax
我的输出应该是这样的:
'(57 -4)