开发者

How to read the data from text file in Prolog

开发者 https://www.devze.com 2023-04-03 19:10 出处:网络
How do I read data from a text file in Prolog? Is there any example of file reading in SWI-pro开发者_如何转开发log?readfacts:-

How do I read data from a text file in Prolog? Is there any example of file reading in SWI-pro开发者_如何转开发log?


readfacts:-
    open('example.txt',read,In),
    repeat,
    read_line_to_codes(In,X),writef(" "),
    writef(X),nl,
    X=end_of_file,!,
    nl,
    close(In).


Prolog has a number of input/output predicates, falling into two categories: the new ISO ones or the old ones compatible with Edinburgh and DEC 10 versions. For full details including example code, see the reference manual following above links.

0

精彩评论

暂无评论...
验证码 换一张
取 消