We have these functions
foo x1 x2 ... xN =
f1 x =
f2 x =
...
fN x =
Is there idiomatic pointfree version of this function?
bar x1 x2 ... xn = foo (f1 x1) (f2 x2) ... (fN xN)
edit
If not can we somehow generalize this function to N parameters?
applyF3 f f1 f2 f3 x1 x2 x3 = f (f1 x1) (f2 x2) (f3 x3)
bar = applyF3 foo f1 f2 f3
Not really idiomatic:
import Control.Arrow
bar = curry . curry $ (f1 *** f2) *** f3 >>> (uncurry . uncurry $ foo)
Add more curry/uncurry
s for more arguments.
The pointful version is much more clear.
If we have this set of functions
uncurryPairsN f (x1,(x2,...)) = f x1 x2 ... xN
curryPairsN f x1 x2 ... xN = f (x1, (x2, ...))
then
bar = curryPairsN $ uncurryPairsN foo . (f1 *** f2 *** ... *** fN)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With