ML 语言中的 cdr 字符串
我尝试在 ML
中找到一个等于 Scheme
中的 (cdr string) 的库函数(意思是 (cdr abcd) = bcd)。
I try to find a library function in ML
that equal to (cdr string) in Scheme
(meaning (cdr abcd) = bcd).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(假设 SML)
另一种方法是将字符串转换为字符列表(爆炸),然后你可以选择拿走头部(hd) 或 tail (tl),然后最后将其转换回字符串(implode):
字符串转换函数可以在 < a href="http://www.standardml.org/Basis/string.html" rel="nofollow">String 模块,head 和 tail 函数可以在 List 模块
显然你也可以在这里使用 substring 方法,但是在 SML 中你有 extract 函数在这种情况下非常方便:
给它 <代码>无参数使其提取直到字符串末尾。
(Asuming SML)
Another way is to convert the string to a list of chars (explode), then you have the option to take the head (hd) or tail (tl), and then finally convert it back to a string (implode):
The string conversion functions can be found in the String module, and the head and tail functions can be found in the List module
Obviously you can also use the substring method here, however in SML you have the extract function that are quite convenient in this case:
Giving it the
NONE
argument makes it extract until the end of the string.假设使用 Ocaml 方言,您可以使用标准 String模块例如
Assuming the Ocaml dialect, you could use the standard String module with e.g.