(defmacro while (test &rest body) `(do () ((not ,test)) ,@body)) (defun quicksort (vec l r) (let ((i l) (j r) (p (svref vec (round (+ l r) 2)))) (while (<= i j) (while (< (svref vec i) p) (incf i)) (while (> (svref vec j) p) (decf j)) (when (<= i j) (rotatef (svref vec i) (svref vec j)) (incf i) (decf j))) (if (> (- j l) 1) (quicksort vec l j)) (if (> (- r i) 1) (quicksort vec i r))) vec) ;(defmacro while (test &rest body) ; `(do () ; ((not ,test)) ; ,@body)) ;(deftest test-quicksort2() ; (check ; (equal "#(1 2 4 6 7 9 8)" (format nil "~A" (quicksort (vector 8 9 4 2 6 7 1) 0 6)))