Advertisement
Guest User

INSERT/INSERTSORT

a guest
Apr 25th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.25 KB | None | 0 0
  1. (define (insert xs n)
  2.   (cond [(null? xs) (cons n null)]
  3.         [(< n (car xs)) (cons n xs)]
  4.         [else (cons (car xs) (insert (cdr xs) n))]))
  5.  
  6. (define (insert-sort xs)
  7.   (if (null? xs)
  8.       null
  9.       (insert (insert-sort (cdr xs)) (car xs))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement