fork download
  1. ; Quick sort in LISP
  2. (defparameter *list* (list))
  3.  
  4. (dotimes (n 10)
  5. (defparameter *list* (append *list* (list (random 100))))
  6. )
  7.  
  8. (defun swap(lst i j)
  9. (rotatef (nth i lst) (nth j lst))
  10. )
  11.  
  12. (defun quick-sort(lst)
  13. (dotimes (i (list-length lst))
  14. (dotimes (j (list-length lst))
  15. (if (< (elt lst i) (elt lst j))
  16. (swap lst i j)
  17. )
  18. )
  19. )
  20. )
  21.  
  22. (print *list*)
  23. (quick-sort *list*)
  24. (print *list*)
  25.  
  26.  
Success #stdin #stdout 0.02s 10560KB
stdin
Standard input is empty
stdout
(83 96 64 40 94 58 3 77 64 95) 
(3 40 58 64 64 77 83 94 95 96)