Reputation: 12819
I'm writing a function that implements the Secant Method for a math utility library.
I'd really like to call the function with a syntax like:
double rootSecantMethod((double (^)(double))f, double x1, double x2, double xtol);
Where the f
block implements the function being solved.
This is a "global function" in that it lives outside of an Objective-C class. I'm not sure if this is the correct term, but I don't want to call it a "C function" since it's being compiled with objc support.
Is there a way to pass a block parameter to a function that lives outside of a class, or does the compiler not support this?
Upvotes: 0
Views: 83
Reputation: 3521
The problem is that you're placing the argument name in the incorrect place:
double rootSecantMethod(double (^f)(double), double x1, double x2, double xtol);
Upvotes: 3