Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,6 @@
|
|||
(defun quicksort (list &aux (pivot (car list)) )
|
||||
(if (cdr list)
|
||||
(nconc (quicksort (remove-if-not #'(lambda (x) (< x pivot)) list))
|
||||
(remove-if-not #'(lambda (x) (= x pivot)) list)
|
||||
(quicksort (remove-if-not #'(lambda (x) (> x pivot)) list)))
|
||||
list))
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
(defun qs (list)
|
||||
(if (cdr list)
|
||||
(flet ((pivot (test)
|
||||
(remove (car list) list :test-not test)))
|
||||
(nconc (qs (pivot #'>)) (pivot #'=) (qs (pivot #'<))))
|
||||
list))
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
(defun quicksort (sequence)
|
||||
(labels ((swap (a b) (rotatef (elt sequence a) (elt sequence b)))
|
||||
(sub-sort (left right)
|
||||
(when (< left right)
|
||||
(let ((pivot (elt sequence right))
|
||||
(index left))
|
||||
(loop for i from left below right
|
||||
when (<= (elt sequence i) pivot)
|
||||
do (swap i (prog1 index (incf index))))
|
||||
(swap right index)
|
||||
(sub-sort left (1- index))
|
||||
(sub-sort (1+ index) right)))))
|
||||
(sub-sort 0 (1- (length sequence)))
|
||||
sequence))
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
(defun quicksort (list)
|
||||
(when list
|
||||
(destructuring-bind (x . xs) list
|
||||
(nconc (quicksort (remove-if (lambda (a) (> a x)) xs))
|
||||
`(,x)
|
||||
(quicksort (remove-if (lambda (a) (<= a x)) xs))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue