Chapter 7

Chapter 7 - Teach Yourself Scheme in Fixnum Days [Go to...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Teach Yourself Scheme in Fixnum Days [Go to first , previous , next page; contents ; index ] Chapter 7 I/O Scheme has input/output (I/O) procedures that will let you read from an input port or write to an output port. Ports can be associated with the console, files or strings. 7.1 Reading Scheme's reader procedures take an optional input port argument. If the port is not specified, the current input port (usually the console) is assumed. Reading can be character-, line- or s-expression-based. Each time a read is performed, the port's state changes so that the next read will read material following what was already read. If the port has no more material to be read, the reader procedure returns a specific datum called the end-of-file or eof object. This datum is the only value that satisfies the eof-object? predicate. The procedure read-char reads the next character from the port. read-line reads the next line, returning it as a string (the final newline is not included). The procedure read reads the next s- expression. 7.2 Writing Scheme's writer procedures take the object that is to be written and an optional output port argument. If the port is not specified, the current output port (usually the console) is assumed. Writing can be character- or s-expression-based. The procedure write-char writes the given character (without the #\ ) to the output port. The procedures write and display both write the given s-expression to the port, with one difference: write attempts to use a machine-readable format and display doesn't. Eg, write
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This test prep was uploaded on 02/06/2008 for the course CS 4536 taught by Professor Fisler during the Winter '08 term at WPI.

Page1 / 4

Chapter 7 - Teach Yourself Scheme in Fixnum Days [Go to...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online