3 ms·
It is quite reasonably easy enough compared to any real practical programming task. For example: // your ordinary function declarations int plus2(int i) {
by YSFEJ4SWJUVU6 9y ago
It is quite reasonably easy enough compared to any real practical programming task. For example:
// your ordinary function declarations
int plus2(int i) { return i + 2; }
int times2(int i) { return i * 2; }
typedef int (*modfun)(int);
// a very reasonable syntax altogether
modfun get_modfun(bool mul) { return (mul ? times2 : plus2); }
Nests as well if you ever wanted to:
modfun get_modfun_no_mul(bool mul) { return plus2; }
typedef modfun (*modfun_getter)(bool);
modfun_getter get_getter(bool allow_mul_opt) { return (allow_mul_opt ? get_modfun : get_modfun_no_mul); }