Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » HELP! Does anyone know anything about scheme
Closed Thread
Old 11-17-2004, 11:15 PM   #1 (permalink)
 
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  
Old 11-22-2004, 03:31 PM   #2 (permalink)
 
Newb Techie

Join Date: Oct 2004

Posts: 14

LauraP

Default

I figured it out so never mind a reply, thanks
LauraP is offline  
Old 11-23-2004, 02:34 PM   #3 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default

So you were basically implementing a quicksort algorithm in scheme?


Nice job, scheme isn't the nicest language in the world to work with linked lists.
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On