方案中的 "string-map" 是什么?
What is "string-map" in scheme?
当我查看下面的代码时,我看到语法“string-map”。我不明白这是什么意思。有人能解释一下吗?谢谢!
(define (convert-nucleotide nuc)
(case nuc)
((#\C) #\G)
((#\G) #\C)
((#\A) #\U)
((#\T) #\A)))
(define (to-rna dna)
(string-map convert-nucleotide dna))
SRFI-13 string-map
是一个将过程和输入字符串作为参数的过程。
通过将每个字符传递给过程来迭代字符串,预计过程将 return/evaluate 到返回字符串中使用的新字符。
示例:
(char-ucase #\a) ; ==> #\A)
(string-map char-upcase "test") ; ==> "TEST"`
当我查看下面的代码时,我看到语法“string-map”。我不明白这是什么意思。有人能解释一下吗?谢谢!
(define (convert-nucleotide nuc)
(case nuc)
((#\C) #\G)
((#\G) #\C)
((#\A) #\U)
((#\T) #\A)))
(define (to-rna dna)
(string-map convert-nucleotide dna))
SRFI-13 string-map
是一个将过程和输入字符串作为参数的过程。
通过将每个字符传递给过程来迭代字符串,预计过程将 return/evaluate 到返回字符串中使用的新字符。
示例:
(char-ucase #\a) ; ==> #\A)
(string-map char-upcase "test") ; ==> "TEST"`