[Haskell-cafe] Usage of . and $
Jefferson Heard
jeff at renci.org
Tue Mar 6 15:18:40 EST 2007
Nope, I'm asking why
um . IntMap.elems . IntMap.IntersectionWith (\x y -> x*y) queryVector
rationalProjection
won't work.
On Tuesday 06 March 2007 15:14, Jeff Polakow wrote:
> haskell-cafe-bounces at haskell.org 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.
More information about the Haskell-Cafe
mailing list