See section 4.2 for an overview of supported character representations.
put(10)
.user
and the
cursor is not at the left margin.end_of_file
.The following code fragment realises efficient non-blocking copy of data from an input- to an output stream. The at_end_of_stream/1 call checks for end-of-stream and fills the input buffer. Note that the use of a get_code/2 and put_code/2 based loop requires a flush_output/1 call after each put_code/2. The copy_stream_data/2 does not allow for inspection of the copied data and suffers from the same buffering issues.
copy(In, Out) :- repeat, ( at_end_of_stream(In) -> ! ; read_pending_input(In, Chars, []), format(Out, '~s', [Chars]), flush_output(Out), fail ).