Created
February 11, 2016 00:39
-
-
Save ruliana/8016b636123c693934ed to your computer and use it in GitHub Desktop.
Quicksort implemented in Racket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define/match (quicksort elements) | |
[('()) '()] | |
[((list pivot rest ...)) | |
(define (<pivot x) (< x pivot)) | |
(define-values (small large) (partition <pivot rest)) | |
(append (quicksort small) | |
(list pivot) | |
(quicksort large))]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment