Module charsio

This module provides temporary input/output redirection. The predicate with_output_to/2 re-directs the output for the given goal and retrieves the stream content for each success. The predicate with_input_from/2 redirects the input for the given goal.

Examples:
?- with_output_to(atom(A), (write(foo); write(bar))).
A = foo ;
A = bar ;
No

?- with_input_from(atom('foo.\n'), read(X)).
X = foo ;
No

The predicate with_output_to/2 is non-deterministic for non-deterministic goals and will return different data results for each success. The predicate with_output_to/2 and with_input_from/2 recognize the same data formats.

The following charsio predicates are provided:

with_output_to(C, G):
The predicate succeeds whenever the goal G succeeds and unifies C with each data result. The predicate recognizes the same data formats as the predicate memory_read/3.
with_input_from(C, G):
The predicate succeeds whenever the goal G succeeds where C defines the initial data. The predicate recognizes the same data formats as the predicate memory_read/3.


Kommentare