I\'m building a pipe with Ramda.js which accepts three arguments. The first function needs those three arguments, and it\'s result is used in the second function. However, the s
I can think of a few solutions:
Wrap your pipe inside another function so that functions in your composition can still refer to the original parameters.
Here func2
accepts the output of func1
but also has access to the initial b
parameter. Obviously func2
must be curried and be designed to accept its "data" as the last parameter (which is a tenet of Ramda and functional programming in general I'd say).
const func3 = (a, b, c) =>
pipe(func1, func2(b))
(a, b, c);
func3(10, 20, 30);
Other option, func1
returns an array which you can destructure in func2
.
I don't think this is particularly nice but it is an option:
const func1 = (a, b, c) => [a + c, b];
const func2 = ([sum, b]) => sum * b;
const func3 = pipe(func1, func2);
func3(10, 20, 30);