predicates
start
comp_str(string,string)
comp_char(char,string)
goal
clearwindow,
start.
clauses
start:-
comp_str("abcd","dcab"),
write("equal"),nl.
start:-
write("not equal"),nl.
comp_str(Str1,Str2):-
Str1 <> "",
frontchar(Str1,Char1,Rest1),
comp_char(Char1,Str2),
comp_str(Rest1,Str2).
comp_str(Str1,Str2):-
Str1 = "".
comp_str(Str1,Str2):-
fail.
comp_char(Char1,Str2):-
frontchar(Str2,Char2,Rest2),
Char1 <> Char2,
Rest2 <> "",
comp_char(Char1,Rest2).
comp_char(Char1,Str2):-
frontchar(Str2,Char2,Rest2),
Char1 = Char2.
comp_char(Char1,Str2):-
fail.