Page 220 - DCAP506_ARTIFICIAL_INTELLIGENCE
P. 220

Artificial Intelligence




                    Notes          The following predicates need the input/output stream to be specified explicitly. The stream is
                                   addressed by a name (alias name or term of open/3/4). You can also  address the  standard
                                   streams by their synonyms.
                                   Predicate                        Purpose
                                   get_byte(@Stream, ?ByteCode)     Read a byte
                                   get_char(@Stream, ?Char)         Read a character
                                   get_code(@Stream, ?CharCode)     Read a character
                                   get_until(@Stream,

                                   +SearchChar, ?Text, ?EndChar)    Read up to a specific character
                                   nl(@Stream)                      Write new line
                                   print(@Stream, @Term)            Write a term
                                   put_byte(@Stream, +ByteCode)     Write a byte
                                   put_char(@Stream, +Char)         Write a character
                                   put_code(@Stream, CharCode)      Write a character
                                   read(@Stream, ?Term)             Read a term
                                   read_term(@Stream, ?Term, @Options)  Read a term with control options
                                   skip_line(@Stream)               Skip input line

                                   write(@Stream, @Term)            Write a term
                                   write_canonical(@Stream, @Term)  Write a term in normal structure representation and
                                                                    in single quotes
                                   write_formatted(@Stream,
                                   +Format, @TermList)              Write terms with formatting

                                   write_term(@Stream, @Term, @Options)  Write a term using operator notation
                                   writeq(@Stream, @Term)           Write a term in single quotes, using operator notation
                                   1cmi [t]13cmKeyboard  inputs are  usually buffered  one  line  at  a  time  and  are  passed  to
                                   the Prolog system  when  is  pressed.  Output  to files  and pipes  is  usually  also buffered.  If
                                   necessary, you can clear the output buffers with flush_output/0/1. You can manage buffering
                                   with open/3/4.
                                   You can utilize the predicate close/1 to close any stream despite the standard streams. Should
                                   you effort to close a standard stream with close/1, it will have no result.

                                   The predicate reset_streams/0 reinstates the defaults for the standard streams



                                      Task  Make  distinction between Input/output  using  current streams  and  explicitly
                                     specified streams.

                                   Self Assessment

                                   Fill in the blanks:
                                   17.  Input/output predicates in which no stream  is mentioned address the  .........................
                                       streams.



          214                               LOVELY PROFESSIONAL UNIVERSITY
   215   216   217   218   219   220   221   222   223   224