<br>
<br><tt><font size=2>haskell-cafe-bounces@haskell.org wrote on 03/06/2007
02:43:03 PM:<br>
<br>
> Usually, I can do this, but today, my brain is weak, and I'm just
trying to <br>
> get this piece of code out the door. My code looks like this:<br>
> <br>
> weight = sum (IntMap.elems (IntMap.intersectionWith <br>
> (\x y -> x*y) queryVector
rationalProjection)) <br>
> <br>
> I know that this will work (ignoring indentation):<br>
> <br>
> sum $ IntMap.elems $ IntMap.intersectionWith (\x y -> x*y) queryVector
<br>
> rationalProjection<br>
> <br>
> But why won't this?:<br>
> <br>
> sum . IntMap.elems . IntMap.IntersectionWith ...<br>
> <br>
> Is there a difference between the "elegance" of function
composition versus <br>
> application?<br>
></font></tt>
<br><tt><font size=2>I assume your really asking why something like: </font></tt>
<br>
<br><tt><font size=2> (*) $ 2 $ 3</font></tt>
<br>
<br><tt><font size=2>won't work? If so, the reason is that $ associates
to the right. So you should write:</font></tt>
<br>
<br><tt><font size=2> ((*) $ 2) $ 3</font></tt>
<br>
<br><tt><font size=2>If not, could you give the full expression which doesn't
work?</font></tt>
<br>
<br><tt><font size=2>-Jeff</font></tt>
<br>
<br>
<br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">---</span><br>
<br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">This e-mail may contain confidential and/or privileged information. If you </span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">are not the intended recipient (or have received this e-mail in error) </span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">please notify the sender immediately and destroy this e-mail. Any </span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">unauthorized copying, disclosure or distribution of the material in this </span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">e-mail is strictly forbidden.</span><br>