-
-
Save rightfold/5126a635281f2559767b 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
$ cat foo.c | |
#include <stdio.h> | |
void repeat(int n, void (^block)(int)) { | |
for (int i = 0; i < n; ++i) { | |
block(i); | |
} | |
}; | |
int main() { | |
int x = 42; | |
repeat(10, ^(int n) { | |
printf("%d\n", x + n); | |
}); | |
return 0; | |
} | |
$ clang foo.c && ./a.out | |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 | |
51 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment