-
Lambda functions in C?
I need to be able to pass in mathematical equations to a program, have the program parse them, and use those equations as lambda/anonymous functions. I know higher level languages are able to do this, but I would prefer the lowest level language due to the computational intensity of this algorithm.
Just as an example:
Code:
intialize x, y, z
y = 2
z = 3
lambda function here (parse string parameter)
print x
where if 'x = y + z' as passed as a parameter, it would print 5, and if 'x = y + 2*z' was passed as a parameter, it would print 8
If this isn't possible in C, what's the next fastest language that is able to implement this?
-
That's not going to be pretty in C - you'll have to pass your equations as string, and write some code to parse them using strtok().
-
You're best off using a scripting language. Without one, you'd basically be wrting a mini scripting language parser yourself anyway.