Think of cleave as the conceptual inverse of map. If map applies a function to each number in a list...
map([1, 2, 3], x -> x * 5) ->
[5, 10, 15]
then cleave applies each function in a list to a number.
cleave(5, [x -> x * 2, x -> x - 1, x -> x * x]) ->
[10, 4, 25]
More formally, given:
- \$n\$, an integer, and
- \$L\$, a list of black box functions with type signature
integer -> integeror equivalent
Apply each function in \$L\$ to \$n\$, collecting the results in a list the same length as \$L\$. (It can be the same list if you want.)
Implement the cleave function in your language of choice.
You must accept an integer and a list of black box functions and output a list of integers in any reasonable format. Argument order doesn't matter. The list of functions is flexible. You may accept:
- A list of black box functions (including a list of function pointers, etc.).
- A variable number of black box functions as parameters (varargs).
- A number indicating how many functions to accept.
- Builtins are allowed, but please consider adding a less trivial answer so we can see how cleave might be implemented in your language.
- Explaining your answer(s) is encouraged!
- Standard loopholes are forbidden.
- This is code-golf, so the code with the fewest bytes (in each language) wins.
Note: for simplicity, instead of showing functions like
x -> 10 * x, I will show them like
10x. Imagine there is an \$f(x) =\$ in front of each of these.
3,  ->  42, [x] ->  0, [10x, x/2, abs(x), -x] -> [0, 0, 0, 0] 8, [10x, x/2, abs(x), -x] -> [80, 4, 8, -8] -5, [abs(x), -x, x+10] -> [5, 5, 5] 5, [abs(x), -x, x+10] -> [5, -5, 15] 10, [x*x, x/10, x*x + 2x + 1, 13, x%3 - 3] -> [100, 1, 121, 13, -2] 950, [x*x, x/10, x*x + 2x + 1, 13, x%3 - 3] -> [902500, 95, 904401, 13, -1]