Simplification of this function?

I've been playing around with this, but haven't been able to come up with anything. myFunc f (a,b) (c,d) = (f a c, f b d) It feels as if there should be a nice simple version of this using some combination of {un,}curry, "on", &&&, ***, or something else. Any thoughts?

<saml> @pl myFunc f (a,b) (c,d) = (f a c, f b d)
<lambdabot> myFunc = (`ap` snd) . (. fst) . flip flip snd . ((flip . (ap .))
.) . flip flip fst . ((flip . ((.) .)) .) . (flip =<< (((.) . flip . (((.) .
(,)) .)) .))
why not use zipWith?
[a,b] `g` [c,d] where g = zipWith f
2009/1/16 Andrew Wagner
I've been playing around with this, but haven't been able to come up with anything. myFunc f (a,b) (c,d) = (f a c, f b d)
It feels as if there should be a nice simple version of this using some combination of {un,}curry, "on", &&&, ***, or something else.
Any thoughts?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Sorry it won't work because list should be homogeneous.
I think your myFunc is standard.
This guy names it "thread":
http://alaska-kamtchatka.blogspot.com/2009/01/essence-of-concatenative-langu...
On Fri, Jan 16, 2009 at 10:32 AM, sam lee
<saml> @pl myFunc f (a,b) (c,d) = (f a c, f b d) <lambdabot> myFunc = (`ap` snd) . (. fst) . flip flip snd . ((flip . (ap .)) .) . flip flip fst . ((flip . ((.) .)) .) . (flip =<< (((.) . flip . (((.) . (,)) .)) .))
why not use zipWith?
[a,b] `g` [c,d] where g = zipWith f
2009/1/16 Andrew Wagner
I've been playing around with this, but haven't been able to come up with anything. myFunc f (a,b) (c,d) = (f a c, f b d)
It feels as if there should be a nice simple version of this using some combination of {un,}curry, "on", &&&, ***, or something else.
Any thoughts?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

2009/1/16 Andrew Wagner
I've been playing around with this, but haven't been able to come up with anything. myFunc f (a,b) (c,d) = (f a c, f b d) It feels as if there should be a nice simple version of this using some combination of {un,}curry, "on", &&&, ***, or something else. Any thoughts? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
uncurry (***) ((first f).(second f) $ (a, b)) (c, d) == uncurry (***) (f a, f b) (c, d) == (f a *** f b) (c, d) == (f a c, f b d) == myFunc f (a, b) (c, d), if I'm not mistaken. Removing the points: uncurry (***) ((first f).(second f) $ (a, b)) == myFunc f (a, b) uncurry (***) . ((first f) . (second f)) == myFunc f uncurry (***) . (first f) . (second f) == myFunc f (associativity of (.)) --Max

"Andrew Wagner"
I've been playing around with this, but haven't been able to come up with anything. myFunc f (a,b) (c,d) = (f a c, f b d)
It feels as if there should be a nice simple version of this using some combination of {un,}curry, "on", &&&, ***, or something else.
Any thoughts?
Yes: Points-free style can quickly become pointless style, if you overuse it. IMO there is nothing wrong with the above definition. It's perfectly clear and concise. Greets, Ertugrul. -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/
participants (4)
-
Andrew Wagner
-
Ertugrul Soeylemez
-
Max Rabkin
-
sam lee