Last active
August 29, 2015 14:20
-
-
Save bsima/d5fce48389b1613d5048 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* A C macro for easily defining lambda functions. | |
* | |
* Source: http://stackoverflow.com/a/3378514/1146898 | |
* | |
* Usage: | |
* | |
* int (*max)(int, int) = lambda (int, (int x, int y) { return x > y ? x : y; }); | |
*/ | |
#define lambda(return_type, function_body) \ | |
({ \ | |
return_type __fn__ function_body \ | |
__fn__; \ | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment