(define hmaxDigit
(lambda (n b)
(cond
((< n 10) n)
((> n (* 10 b)) (hmaxDigit n (* b 10)))
((< 10 (remainder b))
((> (quotient n b) (remainder n b)) (quotient n b))
((< (quotient n b) (remainder n b)) (remainder n b)))))
这就是我所拥有的,但它仅适用于2位数字。
答案 0 :(得分:1)
PartsController
需要填写If n<10 then n is the_maximum_digit
else the_maximum_digit is the maximum of
the first_digit and
the maximum of the remaining digits.
(define (maximum-digit n)
(cond
[(< n 10) n]
[else (max (first-digit n) (maximum-digit (remaining-digits n)))]))
和first-digit
等详细信息。