我正在尝试附加两个字符串列表
但我不知道如何在两个单词之间添加空格。
(define (string-concat lst1 lst2)
(map string-append lst1 lst2)
)
(string-concat '("elementary") "(school))
然后结果为“小学”
合并时如何添加空间? 我尝试过使用 lambda 但它不起作用,例如
(map string-append (cdr (append* (map (lambda (x) list " " x)) lst1)) lst2)
最佳答案
使用 add- Between
在字符串之间添加空格:
> (add-between '("This" "and" "that") " ")
'("This" " " "and" " " "that")
要在列表中追加字符串,请使用string-append*
> (string-append* '("This" " " "and" " " "that"))
"This and that"
你的函数变成:
(define (string-concat lst1 lst2)
(string-append* (add-between (append lst1 lst2) " ")))
其中 append
用于将两个列表合并为一个。
关于方案 - 字符串追加两个字符串列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50850627/