Mapreduce in Clojure
(defn mapreduce [mapfn reducefn lst] (let [rawresult (mapcat mapfn lst)] (let [sorted (sort (fn [x y] (compare (first x) (first y))) rawresult)] (let [keyvals (combinekeys sorted)] (map (fn [lst] (list (first lst) (apply reducefn (rest lst)))) keyvals) ) ) ) ) >(mapreduce identity + '(((a 3) (b 2) (c 1)) ((b 7) (d 3) (c 5)))) ((D 3) (C 6) (B 9) (A 3))