Contents    Page-10    Prev    Next    Page+10    Index   

Iterative Destructive Merge


(defun dmerj (x y)
  (let (front end)
    (if (null x)
        y
        (if (null y)
            x
            (progn
              (if (< (first x) (first y))
                  (progn (setq front x)
                         (setq x (rest x)))
                  (progn (setq front y)
                         (setq y (rest y))))
              (setq end front)
              (while (not (null x))
                (if (or (null y)
                        (< (first x) (first y)))
                    (progn (setf (rest end) x)
                           (setq x (rest x)))
                    (progn (setf (rest end) y)
                           (setq y (rest y))))
                (setq end (rest end)) )
              (setf (rest end) y)
              front))) ))