On Wed, 27 Jul 2011, dokondr wrote:
In your example: 1) I would use: dot = dot' * dot' dot' = sum . elems . intersectionWith (*) norm = sum . fmap (**2) . elems instead of: dot = sum . elems . intersectionWith (*) norm = (**0.5) . sum . fmap (**2) . elems 2) I don't understand the syntax: cosineSimilarity <$> lookup x space <*> lookup y space What are <$> and <*>?
They are from Control.Applicative and are applied to a Maybe type here. It means that cosineSimilarity is applied to the result of looking up 'x' and 'y' in space. If 'x' or 'y' is not in space, then
cosineSimilarity <$> lookup x space <*> lookup y space is Nothing.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe