0

ファイルを読み込んですべてのスペースを削除し、これらを送信 (nl) して、すべてをリストに入れたいと思います。

例:

myfile.txt = (First Line (Second ( line ) and Third and other)
To List = [FirstLine(Second(line)andthirdandother)]

それはどのように達成できますか?

ありがとう

4

1 に答える 1

0

Prolog にread_file_to_codes /3 やcode_type /2 などの適切なビルトインがある場合は、この方法で実行できます。

file_to_list(File, List) :-
  read_file_to_codes(File, Codes, []),
  exclude(bad_char, Codes, List).

bad_char(C) :-
  code_type(C, space).
于 2013-02-08T10:34:27.297 に答える