Hi
You are right =.. is not very efficient. You can use call/2-N to avoid this http://www.gprolog.org/manual/html_node/gprolog042.html#sec194 Also the reverse is time and space consuming. This is strange because you use an accumulator: this is generally used to avoid append or reverse. In fact the accumulator is not needed and avoids the use of reverse. Here is the resulting version: file_codes(From, Out) :- open(From, read, S), file_read_buf(S, get_code, -1, Out), close(S). file_chars(From, Out) :- open(From, read, S), file_read_buf(S, get_char, end_of_file, Out), close(S). file_read_buf(S, Fetcher, Eof, Out) :- call(Fetcher, S, Chr), ( Chr \== Eof -> Out = [Chr|Out1], file_read_buf(S, Fetcher, Eof, Out1) ; Out = [] ). Daniel Le 14/10/2014 00:42, emacstheviking a écrit :
-- Ce message a été vérifié par MailScanner pour des virus ou des polluriels et rien de suspect n'a été trouvé. |
_______________________________________________ Users-prolog mailing list Users-prolog@gnu.org https://lists.gnu.org/mailman/listinfo/users-prolog