Andrew Burgess
Andrew Burgess

Reputation: 1797

Ramda: Call array of functions on array of values

If I have the array data and the array of functions [fn1, fn2, fn3], what's the right way with Ramda to get

[fn1(data[0]), fn2(data[1], fn3(data[2]), ...]

Basically, I want to call each function with the value that shares an array index in the data as its parameter, and get an array of the results.

Upvotes: 1

Views: 678

Answers (1)

Bergi
Bergi

Reputation: 664196

You'll want to use zipWith with call:

R.zipWith(R.call, fns, data)

Upvotes: 5

Related Questions