Created
September 7, 2015 02:24
-
-
Save a3f/2729c1248d0f2ee39b4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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