Skip to content

Instantly share code, notes, and snippets.

@pepijndevos
Created January 11, 2011 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pepijndevos/774664 to your computer and use it in GitHub Desktop.
Save pepijndevos/774664 to your computer and use it in GitHub Desktop.
pigeonhole sort in Clojure
(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