Convert string to Upper and Lower case Turbo Prolo

2019-09-11 17:16发布

问题:

How do I convert a string to Upper and to Lower case in Turbo Prolog.

string_upper and string_lower function is for SWI Prolog,

I found something like,

tolower([], []).
tolower([Upper|UpperTail], [Lower|LowerTail]) :-
char_type(Lower, to_lower(Upper)),
tolower(UpperTail, LowerTail).

But didn't get what exactly it is. Can anyone help me solve this.

回答1:

I did it using upper_lower(),

write("Enter string to convert\n"),
readln(Str1),


upper_lower(Str1,Low),
write("In lower case "),
write(Low),nl,
write("In Upper Case "),
upper_lower(Upp,Str1),
write(Upp). 

The upper_lower Predicate: The upper_lower predicate can be used to convert uppercase characters to lowercase, or lowercase letters to uppercase. The general form of the predicate is upper_lower(UpperCaseString, LowerCaseUpperCaseString)