(defun write-table (table filename) (with-open-file (f filename :direction ':output :if-exists :supersede :if-does-not-exist :create :element-type '(unsigned-byte 8)) (dotimes (i (length table)) (let* ((val (aref table i)) (b0 (logand (ash val -24) #xf)) (b1 (logand (ash val -16) #xf)) (b2 (logand (ash val -8) #xf)) (b3 (logand val #xf))) (write-byte b0 f) (write-byte b1 f) (write-byte b2 f) (write-byte b3 f))))) (defun combine-bytes (byte-0 byte-1 byte-2 byte-3) (declare ((unsigned-byte 8) byte-0 byte-1 byte-2 byte-3)) (+ (ash byte-0 24) (ash byte-1 16) (ash byte-2 8) byte-3)) (defun read-table (table table-size filename) (with-open-file (f filename :direction ':input :if-exists :supersede :if-does-not-exist :create :element-type '(unsigned-byte 8)) (dotimes (i table-size) (setf (aref table i) (combine-bytes (read-byte f) (read-byte f) (read-byte f) (read-byte f))))))