So I want to translate the following Python code into VBA (just toy example to illustrate the issue, details omitted).
def numerical_integration(fun, a, b):
"""
:param fun: callable
:param a, b: float
:return: float
"""
# do something based on both fun and a, b
res = ...
return res
def h(x, k):
"""
helper func
:param x: float, main arg
:param k: float, side param
:return: float
"""
# calc based on both x and k
res = ...
return res
def main_function(k):
"""
:param k: float
:return: float
"""
a, b = 0.0, 1.0
res = numerical_integration(fun=lambda x: h(x, k), a=a, b=b)
return res
The problem is that I don't know how to properly pass something like a "partial" function as argument in VBA. I found how to pass "entire" func in VBA in this post. The idea is to pass the function as a string and then let VBA evaluate the string (something like a Python eval equivalent I guess?). But I don't know how this is gonna help if my function is partial i.e. I want it to be a func on only the first param like lambda x: f(x, k) where the second param is in the context in the main func.
Thanks for any sugguestions in advance.