
6 Mar
2007
6 Mar
'07
5:19 p.m.
On 06/03/07, Nicolas Frisby
Composition with (.) builds a function, but you eventually want an Int, so we can't just use (.), but we can come pretty close.
(sum . IntMap.elems . IntMap.IntersectionWith (\x y -> x*y) queryVector) rationalProjection
Often written: f . g . h $ x This is often prefered to the alternative: f $ g $ h $ x As it's visually lighter, and involves less editing if you wanted to get rid of the x (say, you were eta-reducing the expression). As to why: f . g . h . x doesn't work, (.) can only compose two functions, but x is not a function, it is a value, so you have to apply it to the composite function f . g . h using the ($) operator or parentheses. -- -David House, dmhouse@gmail.com