%trace
domains
file = xinput
strlist = string*
predicates
start
readline(strlist)
createlist(string,strlist,strlist,strlist)
reverselist(strlist,strlist,strlist)
goal
clearwindow,
start.
clauses
start:-
openread(xinput,"data.txt"),
readdevice(xinput),
readline([]).
readline(List):-
not(eof(xinput)),
readln(Line),
createlist(Line,List,Newlist,Act_list),
readline(Act_list).
readline(List):-
reverselist(List,[],Reverselist),
write(Reverselist).
createlist(Line,Oldlist,Newlist,Act_list):-
Line <> "",
fronttoken(Line,Token,Rest),
Newlist = [Token | Oldlist],
createlist(Rest,Newlist,List2,Act_list).
createlist(Line,Oldlist,Newlist,Act_list):-
Act_list = Oldlist.
reverselist([],Inputlist,Inputlist).
reverselist([Head | Tail],List1,List2):-
reverselist(Tail,[Head | List1],List2).