在实践中,您可以使用string-downcase
过程来实现:
(string-downcase "ABCDE")
=> "abcde"
但是由于您正在使用初学者语言,因此解决它的一般思路如下 - 我将给您一些提示,最好尝试自行解决问题。首先,让我们将问题分为两部分:一个过程将字符串转换为字符列表,调用一个帮助程序执行实际转换,最后将转换后的列表重新转换为字符串:
(define (lowercase str)
(<???> ; convert the list of chars into a string
(convert ; call the helper procedure
(<???> str)))) ; convert the string into a list of chars
convert
程序是一个助手程序,它负责将字符列表中的每个字符转换为小写字母:
(define (convert strlst)
(if <???> ; if the list of chars is empty
<???> ; return the empty list
(cons ; else `cons`
(<???> <???>) ; convert to lowercase the first char in list
(convert <???>)))) ; advance recursion over list
“字符串是一个固定长度的字符数组。”
因此,你真正的问题是如何处理数组。 - Sebastian Mach