Created
December 25, 2013 15:07
-
-
Save becojo/8124062 to your computer and use it in GitHub Desktop.
Insertion sort
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 insert [coll, n] | |
(let [parts (split-with (partial > n) coll)] | |
(concat (first parts) [n] (last parts)))) | |
(defn insertion-sort [coll] | |
(reduce (fn [sorted item] | |
(insert sorted item)) nil coll)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment