anchor.diff:      (let ((retval (lzw-enc-finish ctx)))
         (assert (not (null retval)))
         (print retval)
  -      (setf *encoded-seq* (cons retval *encoded-seq*)))))
  +      (setf *encoded-seq* 
  +            (remove-if (lambda (x) (null x))
  +                       (reverse (cons retval *encoded-seq*)))))))
  +
  +
  +;; Returns the last output character at the end of encoding.
  +(defun lzw-enc-finish (ctx)
  +  (assert (not (eq (lzw-enc-ctx-current ctx) (lzw-enc-ctx-tree ctx))))
  +  (node-num (lzw-enc-ctx-current ctx)))
  +
  +
  +;; Queue
  +
  +(defstruct queue 
  +  front
  +  back)
  +
  +(defun queue-put (q x)
  +  (assert (queue-p q))
  +  (if (null (queue-front q))
  +      (setf (queue-front q) (setf (queue-back q) (cons x nil)))
  +      (setf (cdr (queue-back q)) (cons x nil)
  +            (queue-back q) (cdr (queue-back q)))))
  +
  +(defun queue-empty? (q)
  +  (if (null (queue-front q))
  +      t
  +      nil))
  +
  +(defun queue-get (q)
  +  (assert (queue-p q))
  +  (if (queue-empty? q)
  +      (error "Queue is empty."))
  +  (let ((retval (pop (queue-front q))))
  +    (if (null (queue-front q))
  +        (setf (queue-back q) nil))
  +    retval))
  +
   
   ;; Decoding.
   
   (defstruct dec-table-entry
     ;; Points to dec-table-entry that makes prefix of this element.
     prefix
  -  ;; String that this table element adds to its prefix.
  +  ;; List of chars that this table element adds to its prefix.
     rest)
   
   (defstruct lzw-dec-ctx
     ;; Table mapping encoded numbers to strings that they represent.
  -  (table (make-hash-table))
  -  ;; Points to dec-table-entry that was last inserted.
  -  last-inserted
  +  (table (make-array 256 :initial-element nil :fill-pointer t))
  +  ;; Points to dec-table-entry that will be inserted once its
  +  ;; rest field is known.
  +  new-entry
     ;; Points to dec-table-entry that was last decoded.
     last-decoded
     ;; Number of nodes in the table.
  
positive.code: (defun fresh-lzw-dec-ctx ()
    (let ((ctx (make-lzw-dec-ctx :node-count 256)))
      (loop for i from 0 to 255
            do (setf (gethash i (lzw-dec-ctx-table ctx))
                     (make-dec-table-entry :prefix nil :rest i)))
      ctx))
  
  
negative.code:           ;; Return nil as we have nothing to output yet.
            nil))))
  
  ;; A simple test.
  (defvar *input-string* "abaaacaabacdbaaaaaaa")
  (defvar *encoded-seq* nil)
  