[not loaded]PublicShow sourcepio.pl -- Pure I/O

This library provides pure list-based I/O processing for Prolog, where the communication to the actual I/O device is performed transparently through coroutining. This module itself is just an interface to the actual implementation modules.

author
- Ulrich Neumerkel
- Jan Wielemaker

Re-exported predicates

The following predicates are re-exported from other modules

Source phrase_from_file(:Grammar, +File) is nondet
Process the content of File using the DCG rule Grammar. The space usage of this mechanism depends on the length of the not committed part of Grammar. Committed parts of the temporary list are reclaimed by the garbage collector, while the list is extended on demand due to unification of the attributed tail variable. Below is an example that counts the number of times a string appears in a file. The library dcg/basics provides string//1 matching an arbitrary string and remainder//1 which matches the remainder of the input without parsing.
:- use_module(library(dcg/basics)).

file_contains(File, Pattern) :-
        phrase_from_file(match(Pattern), File).

match(Pattern) -->
        string(_),
        string(Pattern),
        remainder(_).

match_count(File, Pattern, Count) :-
        aggregate_all(count, file_contains(File, Pattern), Count).

This can be called as (note that the pattern must be a string (code list)):

?- match_count('pure_input.pl', `file`, Count).

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

Source phrase_from_file(Arg1, Arg2, Arg3)
Source phrase_from_stream(Arg1, Arg2)
Source stream_to_lazy_list(Arg1, Arg2)
Source syntax_error(Arg1, Arg2, Arg3)
Source lazy_list_location(Arg1, Arg2, Arg3)
Source lazy_list_character_count(Arg1, Arg2, Arg3)