- Documentation
- Reference manual
- The SWI-Prolog library
- library(aggregate): Aggregation operators on backtrackable predicates
- library(ansi_term): Print decorated text to ANSI consoles
- library(apply): Apply predicates on a list
- library(assoc): Association lists
- library(broadcast): Broadcast and receive event notifications
- library(charsio): I/O on Lists of Character Codes
- library(check): Consistency checking
- library(clpb): CLP(B): Constraint Logic Programming over Boolean Variables
- library(clpfd): CLP(FD): Constraint Logic Programming over Finite Domains
- library(clpqr): Constraint Logic Programming over Rationals and Reals
- library(csv): Process CSV (Comma-Separated Values) data
- library(dcg/basics): Various general DCG utilities
- library(dcg/high_order): High order grammar operations
- library(debug): Print debug messages and test assertions
- library(dicts): Dict utilities
- library(error): Error generating support
- library(fastrw): Fast reading and writing of terms
- library(gensym): Generate unique symbols
- library(heaps): heaps/priority queues
- library(increval): Incremental dynamic predicate modification
- library(intercept): Intercept and signal interface
- library(iostream): Utilities to deal with streams
- library(listing): List programs and pretty print clauses
- library(lists): List Manipulation
- library(macros): Macro expansion
- library(main): Provide entry point for scripts
- library(nb_set): Non-backtrackable set
- library(www_browser): Open a URL in the users browser
- library(occurs): Finding and counting sub-terms
- library(option): Option list processing
- library(optparse): command line parsing
- library(ordsets): Ordered set manipulation
- library(pairs): Operations on key-value lists
- library(persistency): Provide persistent dynamic predicates
- library(pio): Pure I/O
- library(portray_text): Portray text
- library(predicate_options): Declare option-processing of predicates
- library(prolog_coverage): Coverage analysis tool
- library(prolog_debug): User level debugging tools
- library(prolog_jiti): Just In Time Indexing (JITI) utilities
- library(prolog_trace): Print access to predicates
- library(prolog_versions): Demand specific (Prolog) versions
- library(prolog_xref): Prolog cross-referencer data collection
- library(quasi_quotations): Define Quasi Quotation syntax
- library(random): Random numbers
- library(rbtrees): Red black trees
- library(readutil): Read utilities
- library(record): Access named fields in a term
- library(registry): Manipulating the Windows registry
- library(rwlocks): Read/write locks
- library(settings): Setting management
- library(statistics): Get information about resource usage
- library(strings): String utilities
- library(simplex): Solve linear programming problems
- library(solution_sequences): Modify solution sequences
- library(tables): XSB interface to tables
- library(terms): Term manipulation
- library(thread): High level thread primitives
- library(thread_pool): Resource bounded thread management
- library(ugraphs): Graph manipulation library
- library(url): Analysing and constructing URL
- library(varnumbers): Utilities for numbered terms
- library(yall): Lambda expressions
- The SWI-Prolog library
- Packages
- Reference manual
A.47 library(readutil): Read utilities
- See also
- -
library(pure_input)
allows for processing files with DCGs.
-library(lazy_lists)
for creating lazy lists from input.
This library provides some commonly used reading predicates. As these predicates have proven to be time-critical in some applications we moved them to C. For compatibility as well as to reduce system dependency, we link the foreign code at runtime and fallback to the Prolog implementation if the shared object cannot be found.
- [det]read_line_to_codes(+Stream, -Line:codes)
- Read the next line of input from Stream. Unify content of the lines as a list of character codes with Line after the line has been read. A line is ended by a newline character or end-of-file. Unlike read_line_to_codes/3, this predicate removes a trailing newline character.
- [det]read_line_to_codes(+Stream, -Line, ?Tail)
- Difference-list version to read an input line to a list of character
codes. Reading stops at the newline or end-of-file character, but unlike read_line_to_codes/2,
the newline is retained in the output. This predicate is especially
useful for reading a block of lines up to some delimiter. The following
example reads an HTTP header ended by a blank line:
read_header_data(Stream, Header) :- read_line_to_codes(Stream, Header, Tail), read_header_data(Header, Stream, Tail). read_header_data("\r\n", _, _) :- !. read_header_data("\n", _, _) :- !. read_header_data("", _, _) :- !. read_header_data(_, Stream, Tail) :- read_line_to_codes(Stream, Tail, NewTail), read_header_data(Tail, Stream, NewTail).
- [det]read_line_to_string(+Stream, -String)
- Read the next line from Stream into String. String
does not contain the line terminator. String is unified with
the atom
end_of_file
if the end of the file is reached.- See also
- read_string/5 can be used to read lines with separated records without creating intermediate strings.
- [det]read_stream_to_codes(+Stream, -Codes)
- [det]read_stream_to_codes(+Stream, -Codes, ?Tail)
- Read input from Stream to a list of character codes. The version read_stream_to_codes/3 creates a difference-list.
- [det]read_file_to_codes(+Spec, -Codes, +Options)
- Read the file Spec into a list of Codes. Options
is split into options for absolute_file_name/3
and open/4. In addition, the
following option is provided:
- tail(?Tail)
- Read the data into a difference list Codes
\
Tail.
- See also
- phrase_from_file/3 and read_file_to_string/3.
- [det]read_file_to_string(+Spec, -String, +Options)
- Read the file Spec into a the string String. Options
is split into options for absolute_file_name/3
and open/4.
- See also
- phrase_from_file/3 and read_file_to_codes/3.
- [det]read_file_to_terms(+Spec, -Terms, +Options)
- Read the file Spec into a list of terms. Options
is split over
absolute_file_name/3, open/4
and read_term/3. In
addition, the following option is processed:
- tail(?Tail)
- If present, Terms
\
Tail forms a difference list.
Note that the output options of read_term/3, such as
variable_names
orsubterm_positions
will cause read_file_to_terms/3 to fail if Spec contains multiple terms because the values for the different terms will not unify.