Created
June 21, 2014 03:28
-
-
Save toctan/9b515faac43097e6f455 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) (quicksort vec l j)) | |
(if (> r i) (quicksort vec i r))) | |
(princ vec) | |
(terpri) | |
vec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment