Forked from phimuemue/Little C extension - explanation
Last active
August 31, 2015 07:25
-
-
Save raaka1/0a1a99da13c68ac4ea52 to your computer and use it in GitHub Desktop.
This file contains hidden or 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<stdio.h> | |
| #define MAXSIZE 20 | |
| volatile char counterarray[MAXSIZE] = {0}; | |
| #define MAXDEPTH 10 | |
| int depth=0; | |
| int olddepth=0; | |
| int searcher=0; | |
| int searchermax[MAXDEPTH]; | |
| int counter[MAXDEPTH]; | |
| int lastloop; | |
| #define _ counter[depth] | |
| #define times [counterarray]=1; \ | |
| depth++; \ | |
| searcher = 0;\ | |
| for(searcher=-1; counterarray[searcher]==0; ++searcher){ \ | |
| searchermax[depth]=searcher+1; \ | |
| } \ | |
| counterarray[searcher] = 0; \ | |
| for(counter[depth]=0; \ | |
| olddepth=depth, \ | |
| (lastloop=!!(counter[olddepth]<searchermax[olddepth])), \ | |
| counter[olddepth]==searchermax[olddepth]?depth--:1, \ | |
| olddepth = depth, \ | |
| lastloop; \ | |
| _=counter[olddepth]++) | |
| #define NEWLINE printf("\n") | |
| int main(int argc, char** argv){ | |
| printf("3 times hello:\n"); | |
| 3 times printf("Hello.\n"); | |
| NEWLINE; | |
| printf("Now a simple football match simulation:\n"); | |
| 3 times printf("Score: 0 : %d\n", _); | |
| NEWLINE; | |
| printf("Nested tests\n"); | |
| 2 times { | |
| printf("Counting: "); | |
| 9 times { | |
| printf("%d ", _); | |
| } | |
| printf("\n"); | |
| } | |
| NEWLINE; | |
| 5 times { | |
| printf("Counting up to %d: ", _); | |
| _ times { | |
| printf("%d ", _); | |
| } | |
| printf("\n"); | |
| } | |
| NEWLINE; | |
| printf("Some identity matrices:\n"); | |
| 7 times { | |
| printf("Dimension %d\n", _); | |
| int n = _; | |
| n times { | |
| int outer = _; | |
| n times { | |
| printf("%c ", (_==outer?'1':'0')); | |
| } | |
| printf("\n"); | |
| } | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment