The Weak Reference

The Weak Reference

Kurser i Domain-Driven Design - Våren 2012

Tuesday, November 17, 2009

Tuesday, November 03, 2009

From Java to Clojure, followup followup

Martin Lübcke came up with this solution to the frequency sorting problem presented in the PNEHM article From Java to Clojure:

(defn order-by-freq [coll]
(keys (sort-by #(vector (- (frest %)) (first %)) (frequencies coll))))
Replace frest with fnext for Clojure 1.0.

When it comes to performance, this version is about as fast as the original version in the article, but it sure is compact, and surprisingly readable. Many thanks to Martin!