1

I want to print a ASCII value of a character. I am using GNU prolog.

Everything I have tried during 1h hasn't worked. So I came here and I have seen this post: Prolog - get_code/1 without prompt

However, For every character in input, It write 10. Here is my code :

my_get_code(C) :- get_linedit_prompt(''), get_code(C).

/*
lower_case(X,Y) :- 
   my_get_code(X), Y = X.
*/
/*
lower :-
   read(X),
   lower_case(X,Y),
   write(Y).
*/
lower :-
   read(X),
   my_get_code(X),
   write(X).

In fact, my goal is to take a value of an ASCII character and then, convert uppercase into lowercase. I need to get tha ascii value and then add 32 in order to have the lower_case value.

  • 2
    `get_code(C), Cl is C + 32, put_code(Cl).` This should take uppercase char and print corresponding lower case char. I am not exactly sure what else you are asking? – rajashekar Sep 12 '21 at 13:13

0 Answers0