Skip to content

Instantly share code, notes, and snippets.

@moniyax
Last active August 29, 2015 14:07
Show Gist options
  • Save moniyax/e6c9bf72ee0c0957e1ad to your computer and use it in GitHub Desktop.
Save moniyax/e6c9bf72ee0c0957e1ad to your computer and use it in GitHub Desktop.
#lang racket
(define (isort cs)
(define (insert x xs)
(cond [(empty? xs) (list x)]
[else (if (< x (first xs))
(cons x xs)
(cons (first xs) (insert x (rest xs))))]))
(cond [(empty? cs) cs]
[else (insert (first cs) (isort (rest cs)))]))
(module+ test
(require rackunit)
(check-equal? (isort '(4 6 7 3 45 9 7 5)) '(3 4 5 6 7 7 9 45)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment