我正在尝试创建一个将列表中的部分字符串连接到另一个字符串的函数.我已经知道如何选择我想要的字符串,但现在我需要它们的第一部分(并且它并不总是相同的值).
所以我想剪掉一个字符串的第一部分
-- here is a function who should take a string and the numbers
-- of characters we want to take from the start
cutString :: Int -> String -> String
cutString x str = cut x str -- here's a way to take the first x characters
Run Code Online (Sandbox Code Playgroud)
以及使用它的方式:
print (cutString 3 "Hello World")
Output --> "Hel"
Run Code Online (Sandbox Code Playgroud)
有没有简单的方法可以做到这一点?
感谢您提供任何帮助或建议.