next up previous contents
Next: Higher Order Functions Up: Insertion Sort Previous: sorted insertion into a   Contents

'insertion-sort'


(define insertion-sort
   (lambda(l)
      (if (nullp l)
         nil
         (insert (car l)
                  (insertion-sort (cdr l))))))



(define l1 (cons four 
                  (cons one 
                         (cons three 
                                (cons two 
                                       nil)))))
;
(ldisp! l1)
                             --> 4
                                 1
                                 3
                                 2
;
(ldisp! (insertion-sort l1))
                             --> 1
                                 2
                                 3
                                 4



Georg P. Loczewski 2004-03-05


Impressum und Datenschutz