Is there an alphabetic character check in the prologue?
Hello,
Is there a test or predicate I can use in the prologue to make sure that a certain given character is alphabetic? Right now, I am doing:
List of unresolved 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
These are just some of the symbols I need to check. having a test like the letter (Ch). will save me a lot of time and, above all, become a more defensive approach.
thank
+2
source to share
2 answers
In SWI-Prolog this is done with char_type / 2 , for example
% X is either a single-character atom or a character code
alphabetical(X) :- char_type(X, alpha).
SWI-Prolog also offers the ctypes library which provides is_alpha
etc.
:- use_module(library(ctypes)).
alphabetical(X) :- is_alpha(X).
+1
source to share