[Haskell-cafe] Re: Looking for pointfree version (Kim-Ee Yeoh)
(02/12)
Gene Arthur
yumagene at inbox.com
Fri Feb 20 00:07:18 EST 2009
>Kim-Ee Yeoh said:
>On the same note, does anyone have ideas
>for the following snippet? Tried the pointfree
>package but the output was useless.
>pointwise op (x0,y0) (x1,y1) = (x0 `op` x1, y0 `op` y1)
First sorry for the delay in getting to this.. been behind on
projects so had some days of mail piled up. Here is what
I came up with, using one arrow operator,
so you would have to import: Control.Arrow ((***)) at minimum
to use this solution:
pointfree ::
forall t t1 c. (t -> t1 -> c) -> (t, t1) -> (t, t1) -> (c, c)
pointfree op =
curry $ (\(a,b) -> a `op` b) *** (\(a,b) -> a `op` b)
examples of use, that were executed using:
ghci -fglasgow-exts -farrows Control.Arrow
*>pointfree (*) (3,5) (12,12)
(15,144)
*> pointfree (++) ("This ","That") ("Old"," Man")
("This That","Old Man")
Hope that helps.
-- gene
==============================
website: http://haskblog.cloud.prohosting.com
==============================
If Helen Keller is alone in a forest and falls,
does she make a sound?
____________________________________________________________
Receive Notifications of Incoming Messages
Easily monitor multiple email accounts & access them with a click.
Visit http://www.inbox.com/notifier and check it out!
More information about the Haskell-Cafe
mailing list