Bratko, Chapter 6: Input and Output - basic file input - see(Filename) changes current input stream to Filename - see(user) changes current input stream to user (keyboard) - 'seen' closes the current input file - 'end_of_file' read when at end of file - basic file output - tell(Filename) changes current output stream to Filename - tell(user) changes current output stream to user (screen) - 'told' closes the current output file - term i/o - read(X) - X matched with next term T in input stream - read fails if match (X = T) fails - read does not backtrack on failure, attempting to read more terms - T must be a valid term followed by a period and a space or return - X = end_of_file when attempting to read passed end of file - write(X) - writes X to standard output - use 'ttyflush' after write if nothing appears immediately - tab(N) causes N spaces to be output - 'nl' outputs a new line (no arguments) - examples - calculator - displaying lists (p150) - formatting terms (fig6.3) - processing a file of terms (p152) - cat - character i/o - get(C) reads a single character, ignoring whitespace - get0(C) reads a single character, including whitespace - put(C) outputs character whose ASCII code is C - 0 <= C <= 127, (C = -1) ==> EOF - examples - ascii converter - cat2 - format ??? - constructing and decomposing atoms - name(A,L) is true if L is the list of ASCII codes of the chars in A - examples - sentence to list [Fig 6.4] - plurals [Exer 6.5] + special cases - reading programs - consult(F) - reads in clauses from file F - another consult adds clauses to end of current clauses, even if clauses have the same name as previously consulted clauses - reconsult(F) - same as consult, but for any clauses in F already existing, the existing clauses are replaced by the new clauses in F - HW2 - blocks-world state visualizer - monkey-bananas state visualizer - Exercise 6.6