Created
August 23, 2011 14:45
-
-
Save mamboking/1165309 to your computer and use it in GitHub Desktop.
sort by length & frequency
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
;;Hett's Problem 1.28 | |
(def test-list [[:a :b :c] [:d :e] [:f :g :h] [:d :e] [:i :j :k :l] [:m :n] [:o]]) | |
(defn sort-by-length [some-list] | |
(sort-by count some-list)) | |
(defn sort-by-length-freq [some-list] | |
(let [freq-map (frequencies (map count test-list))] | |
(sort-by (fn [l] (freq-map (count l))) some-list))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment