Last active
June 21, 2016 19:08
-
-
Save 6ewis/810577150f4b252e8faa69e7060bf3af 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
(defn remove-one [item list] | |
(let [[n m] (split-with (partial not= item) list)] (vec (concat n (rest m))))) | |
(defn sorting-sort [unsorted] | |
(loop [inner-unsorted unsorted sorted []] | |
(let [min-val (apply min inner-unsorted)] | |
(if | |
(or | |
(= 1 (count inner-unsorted)) | |
(empty? inner-unsorted)) | |
sorted | |
(recur (remove-one min-val inner-unsorted) (conj sorted min-val)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment