I'm trying to do a quicksort implementation in scheme using a partition that takes two arguement, a pivot and a list.
If I were to run:
=>(partition '3 '(5 7 8 6 4 2 1))
I want the output to be:
=>;Value: ((2 1) (3 5 7 8 6 4))
I'm using this code:
(define (partition lt? lst)
(if (null? lst)
(values '() '())
(let ((rest (cdr lst)))
(if (lt? (car lst) (car rest))
(let ((left (partition lt? rest)))
(values (cons (car lst) (car left))
(cdr left)))
(let ((right (partition lt? rest)))
(values (car right)
(cons (car lst) (cdr right)))))))
It gives the following error: Output