Test Topics for 2nd Quarter Test 1
1. Chapter 9: format, with-open-file, read, read-line, read-char,
dotimes, do
- p.136 general format of with-open-file
- p.137 reading a specific number of items from a file
with dotimes
- p.137 reading until eof with do loop
Note: for clisp, the syntax of the "read" needs a
third argument for the symbol that is returned
when end of file is reached:
(do ((patient (read patient-stream nil 'eof)
(read patient-stream nil 'eof)))
((eql patient 'eof) 'done) ;;or return t or nil
(format t "Patient:~a~%" patient)
)
- p.138 writing to files
Remember for clisp the syntax of the read needs to have
the third argument: (read patient-stream nil 'return-symbol)
And the end test needs to be changed:
((eql patient 'return-symbol) 'return-value)
- p.141-143 strings and characters, #\character
> (elt "abc" 2) returns #\c
- p.143-145 read-line and read-char
Remember for clisp:
(read-line line-stream nil 'return-symbol)
and the end test is:
((eql line 'return-symbol) 'return-value)
For example: (read-line line-stream nil 'eof)
and the end test is:
((eql line 'eof) 'done)
Also see Help on File Reading
and Image starter files
for more examples of file reading.
2. Chap. 11 Arrays: make-array, aref, and setf. Also know "let"
for local variable declarations.
- p.163 make-array
For two or more dimensions you need to use a list
- p.164 make-array :initial-contents
- p.165 aref and setf
- Also see the above "Image starter files" link for more examples.
3. Chap. 13 Structures: defstruct, make-, field (slot) accessors,
structure type predicates, :include
- p.176 general structure form
- p.177 "make-" constructor
- p.178 accessing structure fields
- p.179-180 inheriting fields from another structure with :include
4. Chap. 14 Classes and Defmethod, make-instance,
:accessor, :initform, :initarg
- p.186 defmethod
- p.188 class form
- p.189-194 make-instance, defining classes, inheritance
Know how to translate from structure to class or vice versa.
5. Basics of image files
File formats: P2, P3, P5, P6
Comment lines
How to determine the number of rows and columns of pixels
in an image.
How to determine the maximum pixel value in a file.
See the link: Help with Image files.