Convert string to Upper and Lower case Turbo Prolog

早过忘川 提交于 2019-12-13 05:22:11

问题


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)



来源:https://stackoverflow.com/questions/33464226/convert-string-to-upper-and-lower-case-turbo-prolog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!