いろんな言語で宿題スレat TECH
いろんな言語で宿題スレ - 暇つぶし2ch557:デフォルトの名無しさん
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).


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch