如何在字符集中选择一个字母?
想要这样做:
letters: charset "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
pick letters 2
但是 pick 不适用于 charset 那么我应该使用 charset 来获取位置 2 处的字母?
Would like to do this:
letters: charset "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
pick letters 2
but pick doesn't work with charset so what should I use with charset to get the letter at position 2 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
字符集是“集合”,因此实际上没有“位置”的概念。使用它们,您可以测试成员资格、进行差分、求反等。但它们只是一种优化。
如果您关心“枚举顺序”,那么强制执行顺序的是您的枚举器,而不是集合。
请注意此代码来自
http://www.mail-archive.com/[email protected]/msg16432.html
如果您确实关心顺序,请考虑保留一个系列(例如字符串!)。例如,在上面的示例中,没有什么可以阻止您:
那么您将获得两全其美!
Charsets are "sets" and thus don't really have the concept of a "position". With them you can test for membership, do differencing, negation, etc. But they're just an optimization.
If you care about an "enumeration order" then it is your enumerator which enforces the order, not the set.
Note this code from
http://www.mail-archive.com/[email protected]/msg16432.html
If you actually care about the order, consider keeping a series (e.g. string!) around. e.g. in your example above, nothing is stopping you from making:
Then you get the best of both worlds!