序言中是否有字母字符检查?
您好,
我可以在序言中使用测试或谓词来验证某个给定字符是否是字母顺序的吗?现在,我正在做的是:
非法字符列表:\n -> 10、空间-> 32、!->33、.->46、、->44、:->58、;->59% % 63->? , 45 -> -, 34->", 39-> %
\+member(Ch,[10, 32, 33, 34, 39, 44, 45, 46, 58, 59, 63 ]), %Checking for line return (\n), space, punctuations
这些只是我需要检查的几个字符。进行诸如 letter(Ch) 之类的测试。会节省我大量时间,最重要的是一种更具防御性的方法,
谢谢。
Greetings,
Is there was test or a predicate I can use in prolog to verify that a certain given character is alphabetical? Right now, what I'm doing is:
List of unallawed characters: \n -> 10, space -> 32, !->33, .->46, ,->44, :->58, ;->59%
% 63->? , 45 -> -, 34->", 39-> %
\+member(Ch,[10, 32, 33, 34, 39, 44, 45, 46, 58, 59, 63 ]), %Checking for line return (\n), space, punctuations
Those are only a few of the characters I need to check for. having a test such as letter(Ch). would save me a great deal of time, and above all be a way more defensive approach.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
is_alpha/1
还有其他谓词,例如 is_lower/1 等。
is_alpha/1
There are also other predicates such as is_lower/1 etc.
在 SWI-Prolog 中,这是通过 char_type/2 完成的因为
SWI-Prolog 还提供 ctypes 库,它提供
is_alpha
等In SWI-Prolog, this is done with char_type/2 such as
SWI-Prolog also offers the ctypes library which provides
is_alpha
, etc.