Suppose I have a list of functions that I want to call with the same argument and get a list of results. Here's my setup:
let input = 2
let fns = [add(2), add(3), add(4)]
map(x => x(input), fns)
// this is what I want. Outputs [4, 5, 6]
But I don't quite like the use of the arrow function (purely for stylistic reasons), so I wanted to rewrite it as,
map(call(__, input), fns)
// this doesn't work and produces [[Function],[Function],[Function]]
I can't figure out why x => x(input) isn't equivalent to call(__, input). My thinking is, call(__, input) will return a function that will call its first argument with input.
Can you explain what I'm doing wrong? My hunch is that I have misunderstood the use of __. And how do I use call or some other built-in function to elegantly write this?
I also tried,
// this also works and produces [4, 5, 6]
map(flip(call)(input), fns)
But this also does not sit well with me due to stylistic reasons. I feel like I am shoehorning something with flip, and I also don't like the consecutive function calls (...)(...).