Created
January 25, 2013 17:44
-
-
Save andrei512/4636414 to your computer and use it in GitHub Desktop.
This file contains 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
(def lower_list (list pivot) | |
(if (atom list) | |
(list) | |
(if (le (head list) pivot) | |
(append ((head list)) (lower_list (tail list) pivot)) | |
(lower_list (tail list) pivot) | |
))) | |
(def upper_list (list pivot) | |
(if (atom list) | |
(list) | |
(if (gt (head list) pivot) | |
(append ((head list)) (lower_list (tail list) pivot)) | |
(lower_list (tail list) pivot) | |
))) | |
(def sort (list) | |
(if (atom list) | |
(list) | |
(append (sort (lower_list list (head list))) | |
(sort (upper_list list (head list))) | |
))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment