开发者

How to read the data from text file in Prolog

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜