Browse files

Update to prefer functions in Clojure contrib.

  • Loading branch information...
fffej committed Feb 14, 2009
1 parent a184c6b commit 520bfb3aad5fa449cf5d9d476d356ad16353f64f
Showing with 4 additions and 14 deletions.
  1. +4 −14 huffman.clj
@@ -1,18 +1,7 @@
;;; Huffman encoding
(defn inc-weight
[weight symbol]
(if (contains? weight symbol)
(assoc weight symbol (inc (get weight symbol)))
(assoc weight symbol 1)))
(defn symbol-weights
"Given a list produce a set of symbol weights"
((fn [p weights]
(if (nil? p)
(recur (rest p) (inc-weight weights (first p))))) s {}))
(ns huffman
(:use clojure.contrib.seq-utils))
(defn- sort-by-second [a b]
(< (second a)(second b)))
@@ -77,4 +66,5 @@
(defn compress
[s table]
(mapcat (partial get table) s))
(mapcat (partial get table) s))

0 comments on commit 520bfb3

Please sign in to comment.