[EMAIL PROTECTED] wrote on 03/06/2007 02:43:03 PM:

> Usually, I can do this, but today, my brain is weak, and I'm just trying 
to 
> get this piece of code out the door.  My code looks like this:
> 
> weight = sum (IntMap.elems (IntMap.intersectionWith 
>            (\x y -> x*y) queryVector rationalProjection)) 
> 
> I know that this will work (ignoring indentation):
> 
> sum $ IntMap.elems $ IntMap.intersectionWith (\x y -> x*y) queryVector 
> rationalProjection
> 
> But why won't this?:
> 
> sum . IntMap.elems . IntMap.IntersectionWith ...
> 
> Is there a difference between the "elegance" of function composition 
versus 
> application?
>
I assume your really asking why something like: 

    (*) $ 2 $ 3

won't work? If so, the reason is that $ associates to the right. So you 
should write:

    ((*) $ 2) $ 3

If not, could you give the full expression which doesn't work?

-Jeff



---

This e-mail may contain confidential and/or privileged information. If you 
are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and destroy this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to