%trace
domains
strlist = symbol*
predicates
find_grt(strlist,integer)
find_less(strlist,integer)
% find_len_list(strlist)
% find_len(integer)
names(strlist)
display1(string,integer,integer)
display2(string,integer,integer)
choice(integer)
repeate
clauses
repeate.
repeate :- repeate.
names([harshad,hemal,shashank,abc,nr,khilan,pk]).
/* find_len(CNT) :- CNT1 = CNT / 2.*/
find_grt([H|T],CNT) :-
TMPLIST = [H|T],
str_len(H,LEN),
display1(H,LEN,CNT),
find_grt(T,CNT).
find_less([H|T],CNT) :-
TMPLIST = [H|T],
str_len(H,LEN),
display2(H,LEN,CNT),
find_less(T,CNT).
display1(X,L,CNT) :-
L > CNT, nl,
write(X),
fail.
display1(X,L,CNT).
display2(X,L,CNT) :-
L < CNT, nl,
write(X),
fail.
display2(X,L,CNT).
choice(1) :-
CNT1 = 7 / 2,
names(S_LIST),
find_less(S_LIST,CNT1).
choice(2) :-
CNT1 = 7 / 2,
names(S_LIST),
find_grt(S_LIST,CNT1).
choice(0) :- !.
goal
repeate,
write("\n\n1. Less then"),
write("\n2. Greater then"),
write("\n0. Exit"),
write("\n\nEnter your choice : "),
readint(CH),
choice(CH).