List 在返回scheme中列表最小值的简单脚本中,我的解决方案只返回列表的第一个值。什么';什么是虫子? (定义(最小lst) (续) ((空?(CDR lst))(车辆lst)) (
(最小值’(3 4 2 9 3 8)) 三,List 在返回scheme中列表最小值的简单脚本中,我的解决方案只返回列表的第一个值。什么';什么是虫子? (定义(最小lst) (续) ((空?(CDR lst))(车辆lst)) (,list,scheme,List,Scheme,(最小值’(3 4 2 9 3 8)) 三, 我发现这是第二行正在被评估并返回(任何列表中的汽车)。我缺少什么?第二个条件缺少括号。这使得“你在这两点上都是对的。另外,我将列表拆分两次(以进行比较并返回值)。谢谢! (define (minim lst) (COND ((NULL? (CDR lst)) (CAR lst)) (< (CAR lst) (minim (CDR lst)) (CAR lst)) (ELSE (minim (CDR lst)))) )
我发现这是第二行正在被评估并返回(任何列表中的汽车)。我缺少什么?第二个条件缺少括号。这使得“你在这两点上都是对的。另外,我将列表拆分两次(以进行比较并返回值)。谢谢!
(define (minim lst)
(COND
((NULL? (CDR lst)) (CAR lst))
(< (CAR lst) (minim (CDR lst)) (CAR lst))
(ELSE (minim (CDR lst))))
)
(define (minim lst)
(cond ((null? (cdr lst)) (car lst))
((< (car lst) (minim (cdr lst))) (car lst))
(else (minim (cdr lst)))) )
(minim '(3 4 2 9 3 8))