Skip to content

Instantly share code, notes, and snippets.

@6ewis 6ewis/sorting-sort.clj
Last active Jun 21, 2016

Embed
What would you like to do?
(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
You can’t perform that action at this time.