Skip to content

Instantly share code, notes, and snippets.

@a3f
Created September 7, 2015 02:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a3f/2729c1248d0f2ee39b4a to your computer and use it in GitHub Desktop.
Save a3f/2729c1248d0f2ee39b4a to your computer and use it in GitHub Desktop.
#include <stdio.h>
typedef int (*two_var_func) (int, int);
typedef int (*one_var_func) (int);
int add_int (int a, int b) {
return a+b;
}
#define partial(f, a) ({ \
int g (int b) { \
return (f)((a),b); \
}\
g; \
})
int main (void) {
int a = 1;
int b = 2;
printf ("%d\n", add_int (a, b));
printf ("%d\n", partial(add_int, a) (b));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment