diff options
author | Peter Mikkelsen <peter@pmikkelsen.com> | 2021-07-19 12:44:08 +0000 |
---|---|---|
committer | Peter Mikkelsen <peter@pmikkelsen.com> | 2021-07-19 12:44:08 +0000 |
commit | 1b73b6d1323c69c0086a41bf85a9b85003377a3b (patch) | |
tree | fdb0b85cd4192aac74fb462ed2cadfa1193391ec /stdlib.pl | |
parent | daadb2b174846cda95e51e0c4c94bcb748da4a69 (diff) |
More work on streams
Diffstat (limited to 'stdlib.pl')
-rw-r--r-- | stdlib.pl | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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 :- |