Skip to content

Instantly share code, notes, and snippets.

@6ewis
Last active June 21, 2016 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 6ewis/810577150f4b252e8faa69e7060bf3af to your computer and use it in GitHub Desktop.
Save 6ewis/810577150f4b252e8faa69e7060bf3af to your computer and use it in GitHub Desktop.
(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