Assuming I have a bunch of functions of arity 2: f: a b -> x
, g: c d -> y
,
etc. up to unary function u: a -> a
. What I would like to do is to chain them in such a way:
f(_, g(_, .... z(_, u(_))...)
where inside _
placeholders consecutive values from given input array will be injected. I'm trying to solve this using Ramda
library.
Another, very similar problem I have is chaining the functions the same way but the _
placeholder being filled with the same value against which this composition is being executed.
To be more specific:
// 1st problem
someComposition( f(v[0], g(v[1], ..... z(v[n-1], u(v[n]))...) )(v);
// 2nd problem
someComposition2( f(v, g(v, ..... z(v, u(v))...) )(v);
Best what I could came up with for 2nd problem was, assuming all function are currable, following piece of code (hate it because of the (v)
repetitions):
compose(
z(v),
...
g(v),
f(v),
u
)(v);
I tried solving it with compose
, composeK
, pipe
, ap
but none of them seem to applied to this situation or I just simply am not able to see the solution. Any help is more then welcome.