I am reading the book Programming Collective Intelligence, What exactly the following piece of python code do?
# Add up the squares of all the differences
sum_of_squares=sum([pow(prefs[person1][item]-prefs[person2][item],2)
for item in prefs[person1] if item in prefs[person2]])
I am trying to play with the examples in Java.
Prefs is a map of person to movie ratings, movie ratings is another map of names to ratings.
First it constructs a list containing the results from:
Then it adds those up.