4 ms·
typedef int fn_t(int, int); int iff(bool cond, fn_t a, fn_t b) { if (cond) return(a()); else return(b()); } No
by timewizard 1y ago
typedef int fn_t(int, int);
int iff(bool cond, fn_t a, fn_t b) {
if (cond)
return(a());
else
return(b());
}
Now just write the implementation in terms of a() and b(). I don't get it. C doesn't have convenient syntax but this is compiled and not an evaluated language. This argument didn't make sense to me.
- 1718627440 1y agoI have the same issue with this article. I think it actually complains about the lack of inline anonymous function declarations. The fact that you can't create functions at runtime is only due to needing a compiler. If you link your program against a compiler you can absolutely turn strings into code at runtime and then pass it around to other functions.