[Haskell-beginners] The application of application

David Sabel sabel at ki.informatik.uni-frankfurt.de
Sat Dec 1 23:48:56 CET 2012


A short derivation:

An obvious solution is: Use a lambda abstraction:

   appPair (\x -> (x b) * velocityC) (cos,sin)

or (using function composition)

   appPair ((* velocityC) . (\x -> x b))(cos,sin)

or (explictly using the application operator $):

   appPair ((* velocityC) . (\x -> x $ b))(cos,sin)

Now the lambda abstraction can be removed

   appPair ((* velocityC ) . ($ b)) (cos,sin)


Regards,
  David


Am 01.12.2012 23:31, schrieb Christopher Howard:
> Can application of an expression (to a function) be treated like a
> function itself? In my specific case, I started with this expression:
>
> code:
> --------
> (cos b * velocityC, sin b * velocityC)
> --------
>
> But I have a compulsive hatred of duplication. I happened to have this
> function handy called appPair:
>
> code:
> -------
> appPair f (a, b) = (f a, f b)
>
> appPair (* velocityC) (cos b, sin b)
> -------
>
> Better, but the b identifier is still duplicated. Is there some way I
> could have...
>
> code:
> --------
> appPair (?) (cos, sin)
> --------
>
> ...shifting the application of b into the (* velocityC) expression,
> without modifying my appPair function?
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121201/fab295e3/attachment.htm>


More information about the Beginners mailing list