Проверка, есть ли в строке слова с латинскими буквами
Надо проверить, есть ли в строке слова с латинскими буквами.
Код:
DOMAINS
list_string = string*
number_list = integer*
I = integer
C = char
PREDICATES
nondeterm result
nondeterm str_poisk(string,string)
del_letter(char,string,string)
str_pos(char,string,integer)
str_delete(string,integer,integer,string)
CLAUSES
str_poisk("",Result):-
nl,
write(" Words with latin letters: "),nl,
write(Result),nl.
str_poisk(Sin,Letter):-
frontchar(Sin,C,S1),
del_letter(C,Letter,Result),
str_poisk(S1,Result).
del_letter(C,StrIn,StrOut):-
str_pos(C,StrIn,Npos),
Npos > 0, !, str_delete(StrIn,Npos,1,StrOut); str_delete(StrIn,1,0,StrOut).
str_pos(C,S,1):-
frontchar(S,C,_),!.
str_pos(_,_,0).
str_delete(S,I,C,SO) :-
I1 = I - 1,
frontstr(I1,S,S1,S2),
frontstr(C,S2,_,S3),
concat(S1,S3,SO).
result:-
nl, nl,
write(" 4. Check if there are words with latin letters in the string."), nl,
write(" Enter the string: "),
readln(Str),
Letter = "abcdefghijklmnopqrstuvwxyz",
str_poisk(Str,Letter),
readchar(_),!.
GOAL
result.
list_string = string*
number_list = integer*
I = integer
C = char
PREDICATES
nondeterm result
nondeterm str_poisk(string,string)
del_letter(char,string,string)
str_pos(char,string,integer)
str_delete(string,integer,integer,string)
CLAUSES
str_poisk("",Result):-
nl,
write(" Words with latin letters: "),nl,
write(Result),nl.
str_poisk(Sin,Letter):-
frontchar(Sin,C,S1),
del_letter(C,Letter,Result),
str_poisk(S1,Result).
del_letter(C,StrIn,StrOut):-
str_pos(C,StrIn,Npos),
Npos > 0, !, str_delete(StrIn,Npos,1,StrOut); str_delete(StrIn,1,0,StrOut).
str_pos(C,S,1):-
frontchar(S,C,_),!.
str_pos(_,_,0).
str_delete(S,I,C,SO) :-
I1 = I - 1,
frontstr(I1,S,S1,S2),
frontstr(C,S2,_,S3),
concat(S1,S3,SO).
result:-
nl, nl,
write(" 4. Check if there are words with latin letters in the string."), nl,
write(" Enter the string: "),
readln(Str),
Letter = "abcdefghijklmnopqrstuvwxyz",
str_poisk(Str,Letter),
readchar(_),!.
GOAL
result.