Advertisement
logicmoo

Untitled

Sep 8th, 2016
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.66 KB | None | 0 0
  1. on_x_rtrace(C):-
  2.    catch(C,E,
  3.      (writeln(E),visible(+all), leash(-all),leash(+exception),C)).
  4.  
  5.  
  6. %% File handling code for prolog
  7.  
  8. save_to_file(File_name, Term) :- %Term should be an instantiated list
  9.     open(File_name, write, Data),
  10.     set_stream(Data,representation_errors(prolog)),
  11.     % set_stream(Data,encoding(utf8)),
  12.     write_results_to_file(Data, Term),
  13.     close(Data).
  14.  
  15. % write to file stream. Saves only the most recently asserted results.
  16. write_results_to_file(Stream, [H|Rest]) :-    
  17.     on_x_rtrace(write(Stream, H)),
  18.     write(Stream, "\n"),
  19.         write_results_to_file(Stream, Rest).
  20.  
  21. write_results_to_file(Stream, []) :-
  22.     write(Stream, "\n"), !.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement