I've been redoing all of my introductory CS assignments in LISP, and have arrived at Huffman compression. It seems to me that the most obvious way to deal with sequences of bits is to put them in a bit vector. This works nicely until I want to read or write to files. I have not been able to figure out how to read or write data from an file a bit vector. Ideally I would like to read the entire file into one large bit vector (or write a large bit vector into a file), but I realize that this is obviously unrealistic. So what I am trying to to is find a way to read small portions of the file at a time, something akin to the following:
Code: Select all
(defparameter *file* (open "foo"))
(read-bits *file* 6) ; read 6 bits
(read-bits *file* 3) ; read 3 bits
Is what I want possible?