09/07/23 22:30:45
>>554 書き直し
% Prolog (2/2) ユーティリティ
get_chars(File,L) :-
open(File,read,Input),
get_char(Input,X),
get_chars(Input,X,L),
close(Input),!.
get_chars(Input,end_of_file,[]) :- !.
get_chars(Input,X,[X|R]) :-
get_char(Input,Y),
get_chars(Input,Y,R) .
put_chars(F,L) :-
open(F,write,Output),
stream_put_chars(Output,L),
close(Output),!.
stream_put_chars(_,[]) :- !.
stream_put_chars(Stream,[Char|R]) :-
put_char(Stream,Char),
stream_put_chars(Stream,R),!.
all([],_).
all([V|R],V) :- all(R,V).