Skip to content

Commit

Permalink
Fix transform-prefs
Browse files Browse the repository at this point in the history
  • Loading branch information
zubchick committed Feb 19, 2012
1 parent b76c573 commit 88cf8c4
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/pci/ch1/recommendations.clj
Expand Up @@ -25,22 +25,14 @@
"Superman Returns" 4}})


(defn- map-get [mp key default]
(or (mp key) default))


(defn- transform-person-prefs [pprefs person]
(reduce merge {}
(map (fn [[film rate]] {film {person rate}})
pprefs)))
(defn transform-prefs [prefs]
(apply merge-with merge
(for [[person pprefs] prefs
[film rate] pprefs]
{film {person rate}})))


(defn transform-prefs [prefs]
(reduce (fn [result [person pprefs]]
(merge-with merge result
(transform-person-prefs pprefs person)))
{}
prefs))
(def movies (transform-prefs critics))


(defn sum-of-squares [x y]
Expand Down

0 comments on commit 88cf8c4

Please sign in to comment.