blob: b622ec9748d6f6520f48424028b203c1d59d65b1 [file] [log] [blame]
swissChili1e8b7562021-12-22 21:22:57 -08001;;; Quicksort
2
3(defun quicksort (l)
4 (if (not l)
5 l
6 (let1 (rest (cdr l))
7 (append
8 (quicksort (remove-if-not
9 (lambda (x)
10 (< x (car l)))
11 rest))
12
13 (list (car l))
14
15 (quicksort (remove-if-not
16 (lambda (x)
17 (> x (car l)))
18 rest))))))
19
20(defun main ()
21 (print
22 (quicksort
23 (list 12 3 4 1 6 8 10 5 14))))