% add this file to mi.pl, or compile separately.
%
% procedures to output query results to file
%

saveResult(Result,File) :-
    tell(File), write(Result), nl, told, nl,
    write('Result saved in '), write(File), write(' .'), nl.

% how to use:
%  the second argument is normally a sequence of alphanumeric characters,
% starting with a lower case letter;  to do anything else, put
% single quotes before and after the filename: eg  '~/results/r1' .
%
% for the first argument, use the variable that you use for the
% result you are computing, eg:
%
% ?- random_tune(X,[]), saveResult(X,result1).
%
% Result saved in result1 .
% X = ['A',b,a,f,f,a,bl,f,b,f,a,d,'A',bl,c,e,a,e,e,a,bl,a,b,d,f,b,'A',bl,
% 'A',b,f,'A',b,'A',bl,b,d,g,d,g,'B',bl,g,b,'B',g,e,d,bl,f,b,'A',d,b,f,bl] ? 
% yes
