- 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(gensym): Generate unique identifiers
- library(intercept): Intercept and signal interface
- library(iostream): Utilities to deal with streams
- library(lists): List Manipulation
- library(main): Provide entry point for scripts
- library(nb_set): Non-backtrackable set
- library(www_browser): Activating your Web-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(predicate_options): Declare option-processing of predicates
- library(prolog_pack): A package manager for Prolog
- library(prolog_xref): Prolog cross-referencer data collection
- library(quasi_quotations): Define Quasi Quotation syntax
- library(random): Random numbers
- library(readutil): Read utilities
- library(record): Access named fields in a term
- library(registry): Manipulating the Windows registry
- library(settings): Setting management
- library(simplex): Solve linear programming problems
- library(solution_sequences): Modify solution sequences
- library(thread_pool): Resource bounded thread management
- library(ugraphs): Unweighted Graphs
- library(url): Analysing and constructing URL
- library(varnumbers): Utilities for numbered terms
- library(yall): Lambda expressions
- The SWI-Prolog library
- Reference manual
- 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
end_of_fileif 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:
- Read the data into a difference list Codes
- [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.
- [det]read_file_to_terms(+Spec, -Terms, +Options)
- Read the file Spec into a list of terms. Options
is split over
and read_term/3. In
addition, the following option is processed:
- If present, Terms
\Tail forms a difference list.
Note that the output options of read_term/3, such as
subterm_positionswill cause read_file_to_terms/3 to fail if Spec contains multiple terms because the values for the different terms will not unify.