root/tags/lgt2311/library/character.lgt

Revision 3687, 1.7 KB (checked in by pmoura, 21 months ago)

Code reformating.

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