From 1b73b6d1323c69c0086a41bf85a9b85003377a3b Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Mon, 19 Jul 2021 12:44:08 +0000 Subject: More work on streams --- stdlib.pl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'stdlib.pl') diff --git a/stdlib.pl b/stdlib.pl index d093eed..c6b395f 100644 --- a/stdlib.pl +++ b/stdlib.pl @@ -110,6 +110,29 @@ open(SourceSink, Mode, Stream) :- close(StreamOrAlias) :- close(StreamOrAlias, []). +flush_output :- + current_output(S), + flush_output(S). + +stream_property(S, P) :- + stream_properties(Props), + member(prop(S,P), Props). + +at_end_of_stream :- + current_input(S), + stream_property(S, end_of_stream(E)), + !, + (E = at ; E = past). + +at_end_of_stream(S_or_a) :- + ( atom(S_or_a) + -> stream_property(S, alias(S_or_a)) + ; S = S_or_a + ), + stream_property(S, end_of_stream(E)), + !, + (E = at; E = past). + % Standard exceptions instantiation_error :- -- cgit v1.2.3