anchor.diff:                    (return-from heap-insert i))))
   
   (defun heap-maximum (heap)
  +  (declare (heap heap))
     (unless (zerop (length heap))
       (aref heap 0)))
   
   (defun heap-extract (heap i &key (key #'identity) (test #'>=))
  +  (declare (heap heap) (array-index i))
     (unless (> (length heap) i)
       (error "Heap underflow"))
     (prog1
  
positive.code: ;;; TODO Allow the heap to have variable arity?
  ;;; http://www.pvk.ca/Blog/2014/04/13/number-systems-for-implicit-data-structures/
  
  (defsubst heap-parent (i)
    (ash (1- i) -1))
  
  (defsubst heap-left (i)
    (1+ (ash i 1)))
  
  (defsubst heap-right (i)
    (+ 2 (ash i 1)))
  
  (defun heapify (heap start &key (key #'identity) (test #'>=))
    (declare (function key test))
    (fbind (key (ge test))
      (let ((l (heap-left start))
            (r (heap-right start))
            (size (length heap))
  
negative.code:   (heap-extract heap 0 :key key :test test))
  
  (defun heap-extract-all (heap &key (key #'identity) (test #'>=))
    (declare (heap heap))
    (loop while (> (length heap) 0)
          collect (heap-extract-maximum heap :key key :test test)))
  
  (defsubst make-heap (&optional (size 100))
    (make-array size :adjustable t :fill-pointer 0))
  
  (defun bestn (n seq pred &key (key #'identity) memo)
  