% ---------------------------------------------------------------------------- % % reversefile.m % Ralph Becket <rbeck@microsoft.com> % Tue Jan 9 11:39:27 GMT 2001 % vim: ts=4 sw=4 et tw=0 wm=0 ff=unix % % ---------------------------------------------------------------------------- % :- module mytest. :- interface. :- import_module io. :- pred main(io__state, io__state). :- mode main(di, uo) is det. :- implementation. :- import_module string, list, require. main --> read_file_reversed([], ReversedLines), io__write_list(ReversedLines, "", io__write_string). :- pred read_file_reversed(list(string), list(string), io__state, io__state). :- mode read_file_reversed(in, out, di, uo) is det. read_file_reversed(RLs0, RLs) --> io__read_line_as_string(Result), ( { Result = ok(Line) }, read_file_reversed([Line | RLs0], RLs) ; { Result = eof }, { RLs = RLs0 } ; { Result = error(ErrNo) }, { error(io__error_message(ErrNo)) } ).