Skip to content

Instantly share code, notes, and snippets.

@Mon-Ouie
Created July 9, 2010 09:04
Show Gist options
  • Select an option

  • Save Mon-Ouie/469254 to your computer and use it in GitHub Desktop.

Select an option

Save Mon-Ouie/469254 to your computer and use it in GitHub Desktop.
#include <stdio.h>
typedef int (^complicated_block)(int, int);
typedef int (^simple_block)(int);
int main(int argc, char *argv[]) {
complicated_block pow = ^(int n, int power) {
int ret = 1;
for (int i = 0; i < power; i++)
ret *= n;
return ret;
};
simple_block pow2 = ^(int power) {
return pow(2, power);
};
printf("2^3 = %d\n", pow2(3));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment