Skip to content

Instantly share code, notes, and snippets.

@serge-rgb
Last active April 15, 2016 01:09
Show Gist options
  • Save serge-rgb/48a13a7182a6745f290b7f48c1c7f37d to your computer and use it in GitHub Desktop.
Save serge-rgb/48a13a7182a6745f290b7f48c1c7f37d to your computer and use it in GitHub Desktop.
moar_lambda.c
#include "sgl.h"
#include "lambda.h"
#include "test_lpp_lambda.h"
typedef int (*IntFunc) (int x, int y);
int main()
{
void* ptr = lambda(void, empty_function, () {} );
lambda(int, my_func_1, (int x, int y) { return x + y; } );
// Declare my_func_1
int four = my_func_1(2, 2);
// <-- testing multiple-identifier types
const int nine = lambda(const int, my_func_2, (int x, int y)
{
return x * y;
}) (3, 3);
IntFunc local = lambda(int, foo,
(int a, int b)
{
int c = 0;
if (a)
{
// Testing 123 }
++c;
/*
* Testing block }
*/
if (b)
{
puts(" Hello from a lambda. This brace is a test -> } ");
++c;
#define ANSWER 42 // Testing defines
}
}
return c;
}
);
int bar = 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