swissChili | 1e8b756 | 2021-12-22 21:22:57 -0800 | [diff] [blame] | 1 | ;;; 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 | |||||
22 | (quicksort | ||||
23 | (list 12 3 4 1 6 8 10 5 14)))) |