このディレクトリの索引

一行読み込む(_行) :-
        get_line(_行).

get_line(Stream,X) :-
        get_char(Stream,C),
        get_line_1(Stream,C,Chars),
        atom_chars(X,Chars).

get_line_1(Stream,'\n',[]) :- !.
get_line_1(Stream,end_of_file,[e,n,d,'_',o,f,'_',f,i,l,e]) :- !.
get_line_1(Stream,C,[C|R]) :-
        get_char(Stream,C2),
        get_line_1(Stream,C2,R).


get_line(X) :-
        get_char(C),
        get_line_1(C,Chars),
        atom_chars(X,Chars).

get_line_1('\n',[]) :- !.
get_line_1(end_of_file,[e,n,d,'_',o,f,'_',f,i,l,e]) :- !.
get_line_1(C,[C|R]) :-
        get_char(C2),
        get_line_1(C2,R).