Did you know ... | Search Documentation: |
Predicate read_string/3 |
octet
encoding. See open/4
and set_stream/2
for controlling the encoding.file_lines(File, Lines) :- setup_call_cleanup(open(File, read, In), stream_lines(In, Lines), close(In)). stream_lines(In, Lines) :- read_string(In, _, Str), split_string(Str, "\n", "", Lines).
This loads all lines to memory as strings. If we use the Unix dictionary words:
?- file_lines("/usr/share/dict/words", Lines). Words = ["A", "a", "aa", "aal", "aalii", "aam", "Aani", "aardvark", "aardwolf"|...].