Created
April 10, 2016 02:14
-
-
Save serge-rgb/506396ed1a0cf9709bccdf6526a109d8 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 "sgl.h" | |
#include "lambda.h" | |
#include "test_lpp_lambda.h" | |
typedef float (*FloatFunc) (int x, int y); | |
int main() | |
{ | |
// Declare my_func_1 | |
lambda(int, my_func_1, (int x, int y) { return x + y; }); | |
int four = my_func_1(2, 2); | |
int nine = lambda(int, my_func_2, (int x, int y) | |
{ | |
return x * y; | |
}) (3, 3); | |
FloatFunc local = lambda(float, foo, (int a, int b) { return sqrtf((float)a*a + (float)b*b); }); | |
float sqrt2 = local(1,1); | |
assert (four == 4); | |
assert (nine == 9); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment