Skip to content

Instantly share code, notes, and snippets.

@serge-rgb
Created April 10, 2016 02:14
Show Gist options
  • Save serge-rgb/506396ed1a0cf9709bccdf6526a109d8 to your computer and use it in GitHub Desktop.
Save serge-rgb/506396ed1a0cf9709bccdf6526a109d8 to your computer and use it in GitHub Desktop.
#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