parsingprologiso-prolog

Parsing from char to digit Prolog


I have the following:

is_digit(X):-char_type(X,digit).

When I call it like this: is_digit(X).

I get the folloring results:

X='0'; 
X='1'; 
... ; 
X='9'

I need to get those same results but without the quotes. Excuse me if it is a simple question but I just haven't been able to find a way around this. Thanks!


Solution

  • If you want the number use atom_number(A,N). i.e.

    ?- char_type(X,digit),atom_number(X,N).
    X = '0',
    N = 0 ;
    X = '1',
    N = 1 ;
    X = '2',
    N = 2 ;
    X = '3',