Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
您将如何设计一个函数,该函数使用一个字符串和一个在字符串的第 i 个位置插入“_”的数字 i?
(define (string-insert n i) (substring n i))
我只需要"_"在让我发疯的第 i 个位置添加
"_"
只需使用string-appendand substring,诀窍就是让索引正确:
string-append
substring
(define (string-insert n i) (string-append (substring n <???> <???>) "_" (substring n <???>)))
我会让你弄清楚细节,你会看到它按预期工作:
(string-insert "HelloWorld" 5) => "Hello_World"