Hello,
I’m trying to implement a bubble sort in OM 6.12 using some Lisp code I came across here: https://en.wikibooks.org/wiki/Algorithm_Implementation/Sorting/Bubble_sort#Common_Lisp
Here’s the code:
(defun bubble-sort (lst)
(loop repeat (1- (length lst)) do
(loop for ls on lst while (rest ls) do
(when (> (first ls) (second ls))
(rotatef (first ls) (second ls)))))
lst)
When I evaluate the resulting function in OM, I just get the input list as a result. What am I doing wrong here?