How can I use function return val as left val in Python?
I want to make the below c code work in Python, how can I make it?
// low level
typedef int* (*func)(int);
// high level
int a[2];
// high level
int* foo(int i) { return &a[i]; }
// low level
void goo(func f) {
int i = 0;
for(; i < 2; ++i) *f(i) = 7;
}
int main(void)
{
goo(foo);
return 0;
}
When I write a low level function such s goo I want to use the pointer
returned by high level user-defined function foo.
It is really easy in c and I want to make it in Python, How? Thanks!!
No comments:
Post a Comment