Created
January 11, 2011 16:26
-
-
Save pepijndevos/774664 to your computer and use it in GitHub Desktop.
pigeonhole sort in Clojure
This file contains hidden or 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
(ns pigeonhole-sort) | |
(defn int-sort [s] | |
(let [listmap (reduce #(update-in | |
(update-in %1 [%2] (fnil inc 0)) | |
[:max] max %2) {:max 0} s)] | |
(mapcat #(repeat (get listmap % 0) %) | |
(range (inc (:max listmap)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment