Click here to Skip to main content
15,920,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to write a program which prints my list in descending order but what i could do it to do it in ascending order. So how do i now convert it to descending?

C++
(define (in-order ls)
  (cond ((null? ls) ls)
        ((< (car ls) (cadr ls)) 
         (cons (car ls) (cons (in-order (cdr ls)) ())))
        ((>= (car ls) (cadr ls)) (car ls))
        (else "Nothing")))


What I have tried:

I tried doing in ascending order. I just need to convert it now
Posted
Updated 22-May-16 8:53am
Comments
CHill60 22-May-16 9:54am    
I don't know Lisp but I would guess that changing < to > and >= to <= might do it
Kornfeld Eliyahu Peter 22-May-16 14:19pm    
And will you be surprised if I told you that it is written in the books (public and accessible via Google)?
+5
CHill60 22-May-16 14:52pm    
No I wouldn't be surprised at all!

1 solution

I've had my comment verified...
I don't know Lisp but I would guess that changing < to > and >= to <= might do it
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900