View Single Post
Old 11-17-2004, 11:15 PM   #1 (permalink)
LauraP
 
Newb Techie

Join Date: Oct 2004

Posts: 14

LauraP

Default HELP! Does anyone know anything about scheme

Could some PLEASE take a look at this I am stuck and I need this figured by mignight TONIGHT. This is all I could come up with.

Given a list you take the first element (5) off the list then you compare it to everything in the list and make a small list and a big list everything in the list less then 5 goes in small list and everything greater goes in big list then you have to sort them and place 5 at the beginning of the big list and concatenate (append) the two list together.

(define quicksort (list ))
(define ls '(5 7 3 1 8 6))
(cond
(( ) )
**I have to come up with some stop condition here**


(define small (x l))
(cond
((null? l) 0)
((> x (car l)) (cons (car l)(small (cdr l))
(else (small(cdr l) ))

(define big (x l))
(cond
((null? l) 0)
((< x (car l)) (cons(car l)(big (cdr l))
(else (small (cdr l) ))

(append (quicksort (small car ls) (cdr ls))))
(cons (car ls) (quicksort (big (car ls) (cdr ls))))
LauraP is offline