[plt-scheme] htdp 22.2.2

From: wooks . (wookiz at hotmail.com)
Date: Wed Jul 19 11:22:25 EDT 2006

http://www.htdp.org/2003-09-26/Book/curriculum-Z-H-28.html#node_sec_22.2

What should I be aiming for here...

I can get

(define (abs-Sort order)
  (local ((define (sort alon)
	    (foldl insert empty alon))
	  (define (insert an alon)
	    (cond
	      [(empty? alon) (list an)]
	      [else (cond
		      [(order an (first alon)) (cons an alon)]
		      [else (cons (first alon) (insert an (rest alon)))])])))
    sort))

(define sortDesc (abs-Sort >))
(define sortAsc (abs-Sort <))
(sortAsc '( 2 3 1 5 4))
(sortDesc '(2 3 1 5 4))

...are there more abstractions I should be applying (say to insert for 
instance).




Posted on the users mailing list.