I have this function:
def apply_function(func, 0, nil, history), do: func.(value, key, history)
def apply_function(func, value, nil, history), do: func.(value, history)
def apply_function(func, value, key, history), do: func.(value, key, history)
It takes an anonymous function and several other values as arguments, then applies the function using said arguments.
Now, I want to check the number of arguments the anonymous functions accepts and apply it to just a subset of the arguments or raise an exception based on that.
I was thinking if it was possible to pattern match func
and discover the number of arguments it can receive, or perhaps I’m overthinking this and the solution is much simpler ?