Skip to content

Instantly share code, notes, and snippets.

@andrei512
Created January 25, 2013 17:44
Show Gist options
  • Save andrei512/4636414 to your computer and use it in GitHub Desktop.
Save andrei512/4636414 to your computer and use it in GitHub Desktop.
(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