projog

3.4. char_type(X,Y) - classifies characters.

Succeeds if the character represented by X is a member of the character type represented by Y. Supported character types are:

Examples

?- char_type(a, digit).

no

?- char_type(a, lower).

yes

?- char_type(a, upper).

no

?- char_type(a, alpha).

yes

?- char_type(a, alnum).

yes

?- char_type(a, white).

no

?- char_type('A', digit).

no

?- char_type('A', lower).

no

?- char_type('A', upper).

yes

?- char_type('A', alpha).

yes

?- char_type('A', alnum).

yes

?- char_type('A', white).

no

?- char_type('1', digit).

yes

?- char_type('1', lower).

no

?- char_type('1', upper).

no

?- char_type('1', alpha).

no

?- char_type('1', alnum).

yes

?- char_type('1', white).

no

?- char_type(' ', digit).

no

?- char_type(' ', lower).

no

?- char_type(' ', upper).

no

?- char_type(' ', alpha).

no

?- char_type(' ', alnum).

no

?- char_type(' ', white).

yes

?- char_type('\\t ', digit).

no

?- char_type('\\t', lower).

no

?- char_type('\\t', upper).

no

?- char_type('\\t', alpha).

no

?- char_type('\\t', alnum).

no

?- char_type('\\t', white).

yes

?- char_type(z, X).
X = alnum

yes;
X = alpha

yes;
X = lower

yes;

no

?- char_type(X, digit).
X = 0

yes;
X = 1

yes;
X = 2

yes;
X = 3

yes;
X = 4

yes;
X = 5

yes;
X = 6

yes;
X = 7

yes;
X = 8

yes;
X = 9

yes;

no

?- char_type(X, upper).
X = A

yes;
X = B

yes;
X = C

yes;
X = D

yes;
X = E

yes;
X = F

yes;
X = G

yes;
X = H

yes;
X = I

yes;
X = J

yes;
X = K

yes;
X = L

yes;
X = M

yes;
X = N

yes;
X = O

yes;
X = P

yes;
X = Q

yes;
X = R

yes;
X = S

yes;
X = T

yes;
X = U

yes;
X = V

yes;
X = W

yes;
X = X

yes;
X = Y

yes;
X = Z

yes;

no

?- char_type(X, lower).
X = a

yes;
X = b

yes;
X = c

yes;
X = d

yes;
X = e

yes;
X = f

yes;
X = g

yes;
X = h

yes;
X = i

yes;
X = j

yes;
X = k

yes;
X = l

yes;
X = m

yes;
X = n

yes;
X = o

yes;
X = p

yes;
X = q

yes;
X = r

yes;
X = s

yes;
X = t

yes;
X = u

yes;
X = v

yes;
X = w

yes;
X = x

yes;
X = y

yes;
X = z

yes;

no

?- char_type(X, alnum).
X = 0

yes;
X = 1

yes;
X = 2

yes;
X = 3

yes;
X = 4

yes;
X = 5

yes;
X = 6

yes;
X = 7

yes;
X = 8

yes;
X = 9

yes;
X = A

yes;
X = B

yes;
X = C

yes;
X = D

yes;
X = E

yes;
X = F

yes;
X = G

yes;
X = H

yes;
X = I

yes;
X = J

yes;
X = K

yes;
X = L

yes;
X = M

yes;
X = N

yes;
X = O

yes;
X = P

yes;
X = Q

yes;
X = R

yes;
X = S

yes;
X = T

yes;
X = U

yes;
X = V

yes;
X = W

yes;
X = X

yes;
X = Y

yes;
X = Z

yes;
X = a

yes;
X = b

yes;
X = c

yes;
X = d

yes;
X = e

yes;
X = f

yes;
X = g

yes;
X = h

yes;
X = i

yes;
X = j

yes;
X = k

yes;
X = l

yes;
X = m

yes;
X = n

yes;
X = o

yes;
X = p

yes;
X = q

yes;
X = r

yes;
X = s

yes;
X = t

yes;
X = u

yes;
X = v

yes;
X = w

yes;
X = x

yes;
X = y

yes;
X = z

yes;

no

white_test :- char_type(X, white), write('>'), write(X), write('<'), nl, fail.

?- white_test.
>\t<
> <

no