0
我發現列表的最大值,現在我想返回數字,除了所有具有MAX值的模數等於零的數字,我不太清楚如何使用整個列表以獲得我需要的任何人都可以引導我這個方向是正確的號碼上模運算符是我迄今爲止在列表上使用模運算符的方案
(define (findlargest a_list)
(if (null? a_list) ;if its a empty list
#f ;its false
(let loop ((a_list (cdr a_list)) ;binds the loop variable a_list to value of cdr a_list(second and all subsequent items in a list)
(maxval (car a_list))) ;maxval is set to car of a_list (first item of the list)
(cond ((null? a_list) maxval) ;if the list is empty return max
((> (car a_list) maxval) ;checks to see if the current element > max
(loop (cdr a_list) (car a_list))) ;find a new max
(else
(loop (cdr a_list) maxval)));keeps the same max