hello every body ,
I tried to sort a list by using the quick sort algorithm
I put this code but I can not get the result
(defun qsort (L)
(if (null L)
nil
(append
(qsort (list< (first L) (rest L)) )
(cons (first L) nil)
(qsort (list>= (first L) (rest L)) )
)
)
)
would some one help me please with this code or if there is another code to do that
quick sort
Forum rules
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
Re: quick sort
And how does the implementation of list< and list>= functions look?
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.
Re: quick sort
I haven't changed your code, just put it in code-tags. I tested it and it works.
You need to define list< and list>= as well since it's a large part that's obviously missing but if they return lists lower and higher than the first element you have (numeric) quick sort
Code: Select all
(defun qsort (L)
(if (null L)
nil
(append
(qsort (list< (first L) (rest L)))
(cons (first L) nil)
(qsort (list>= (first L) (rest L))))))
I'm the author of two useless languages that uses BF as target machine.
Currently I'm planning a Scheme compiler :p
Currently I'm planning a Scheme compiler :p