Predicates
reading
writing
delete
find(integer)
startup(integer)
Database
unsortedDatabase(string,integer)
sortedDatabase(string)
clauses
startup(0).
startup(Num):-
write("Enter String = "),
readln(Name),
str_len(Name,Len),
asserta(unsortedDatabase(Name,Len)),
TempNum = Num - 1,
startup(TempNum).
writing:-
sortedDatabase(Name),
write(Name),nl,
fail.
writing.
find(Index):-
unsortedDatabase(Name,Index),
assertz(sortedDatabase(Name)),
retract(unsortedDatabase(Name,Index)),
find(Index).
find(Index):-
Index = 255.
find(Index):-
TempIndex = Index + 1,
find(TempIndex).
reading:-
NumRead = 10,
startup(NumRead).
delete :-
retract(sortedDatabase(_)),
fail.
delete.
Goal
Clearwindow,
makewindow(1,2,3,"String Operations",0,0,25,80),
reading,!,
find(1),
write("\nString In Increasing Order Of Their Length Are : \n"),
writing,
delete.
Output :-->
+-------------------------------String Operations------------------------------+
¦Enter String = Mayank ¦
¦Enter String = Kesha ¦
¦Enter String = Zunobia ¦
¦Enter String = Slna ¦
¦Enter String = Salna ¦
¦Enter String = Anukul ¦
¦Enter String = Payal ¦
¦Enter String = Shwetambari ¦
¦Enter String = rahul ¦
¦Enter String = raj ¦
¦ ¦
¦String In Increasing Order Of Their Length Are : ¦ ¦ ¦
¦raj ¦
¦Slna ¦
¦rahul ¦
¦Payal ¦
¦Salna ¦
¦Kesha ¦
¦Anukul ¦
¦Mayank ¦
¦Zunobia ¦
¦Shwetambari ¦
¦ ¦
¦Press the SPACE bar ¦
¦ ¦
+------------------------------------------------------------------------------+