root/tags/lgt2210/library/character.lgt

Revision 365, 1.7 KB (checked in by pmoura, 6 years ago)

Changed "authors" key in info/1 directive to "author".

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1
2:- object(character,
3    implements(characterp),
4    extends(atom)).
5
6
7    :- info([
8        version is 1.0,
9        author is 'Paulo Moura',
10        date is 2000/7/24,
11        comment is 'Character predicates.']).
12
13
14    is_alpha('_').
15
16    is_alpha(Char) :-
17        is_letter(Char).
18
19
20    is_letter(Char) :-
21        is_lower_case(Char).
22
23    is_letter(Char) :-
24        is_upper_case(Char).
25
26
27    is_alphanumeric(Char) :-
28        is_alpha(Char).
29
30    is_alphanumeric(Char) :-
31        is_dec_digit(Char).
32
33
34    is_bin_digit(0).
35    is_bin_digit(1).
36
37
38    is_octal_digit(Digit) :-
39        Digit @>= 0,
40        Digit @=< 7.
41
42
43    is_dec_digit(Digit) :-
44        Digit @>= 0,
45        Digit @=< 9.
46
47
48    is_hex_digit(Digit) :-
49        Digit @>= 0,
50        Digit @=< 9.
51
52    is_hex_digit(Digit) :-
53        Digit @>= 'A',
54        Digit @=< 'F'.
55
56    is_hex_digit(Digit) :-
57        Digit @>= a,
58        Digit @=< f.
59
60
61    is_lower_case(Char) :-
62        Char @>= a,
63        Char @=< z.
64
65
66    is_upper_case(Char) :-
67        Char @>= 'A',
68        Char @=< 'Z'.
69
70
71    is_vowel(a).
72    is_vowel(e).
73    is_vowel(i).
74    is_vowel(o).
75    is_vowel(u).
76
77    is_vowel('A').
78    is_vowel('E').
79    is_vowel('I').
80    is_vowel('O').
81    is_vowel('U').
82
83
84    is_layout(' ').
85
86
87    lower_upper(a, 'A').
88    lower_upper(b, 'B').
89    lower_upper(c, 'C').
90    lower_upper(d, 'D').
91    lower_upper(e, 'E').
92    lower_upper(f, 'F').
93    lower_upper(g, 'G').
94    lower_upper(h, 'H').
95    lower_upper(i, 'I').
96    lower_upper(j, 'J').
97    lower_upper(k, 'K').
98    lower_upper(l, 'L').
99    lower_upper(m, 'M').
100    lower_upper(n, 'N').
101    lower_upper(o, 'O').
102    lower_upper(p, 'P').
103    lower_upper(q, 'Q').
104    lower_upper(r, 'R').
105    lower_upper(s, 'S').
106    lower_upper(t, 'T').
107    lower_upper(u, 'U').
108    lower_upper(v, 'V').
109    lower_upper(w, 'W').
110    lower_upper(x, 'X').
111    lower_upper(y, 'Y').
112    lower_upper(z, 'Z').
113
114    lower_upper(Char, Char) :-
115        \+ (Char @>= a, Char @=< z),
116        \+ (Char @>= 'A', Char @=< 'Z').
117
118
119    valid(Character) :-
120        atom(Character),
121        atom_length(Character, 1).
122
123
124:- end_object.
Note: See TracBrowser for help on using the browser.