X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=demos%2Ffor_range.c;h=c96f24cb53b05768f55c127d1f1010f6246d05c5;hb=99cd47b15d13ea0126dab46bcbec912a2f920f24;hp=6aedae7b7e32d7d40a698a59c6c76d622faf72af;hpb=956a4c051a02b9c65d81e644c848e4e2f098da7e;p=svn%2FCll1h%2F.git diff --git a/demos/for_range.c b/demos/for_range.c index 6aedae7..c96f24c 100644 --- a/demos/for_range.c +++ b/demos/for_range.c @@ -2,22 +2,50 @@ program { - int i; + int i,j=1; - printf("for_range(i,0,1)"); - for_range(i,0,1) printf(" [%d]",i); + echo("Just plain vanilla auto-increment:\tfor_range(i,1,5)"); + for_range(i,1,5) + { + printf(" [%d]",i); + } + print(""); - printf("\nfor_range(i,1,0)"); - for_range(i,1,0) printf(" [%d]",i); + echo("Single-evaluation of macro argument:\tj=1; for_range(i,0,j++)"); + for_range(i,0,j++) + { + printf(" [%d]",i); + } + print(""); - printf("\nfor_range(i,1,1)"); - for_range(i,1,1) printf(" [%d]",i); + echo("Just plain vanilla auto-decrement:\tfor_range(i,1,0)"); + for_range(i,1,0) + { + printf(" [%d]",i); + } + print(""); - printf("\nfor_range(i,1,5)"); - for_range(i,1,5) printf(" [%d]",i); + echo("Single iteration is possible too:\tfor_range(i,1,1)"); + for_range(i,1,1) + { + printf(" [%d]",i); + } + print(""); - printf("\nfor_range(i,5,1)"); - for_range(i,5,1) printf(" [%d]",i); + echo("Yet another example of macro safety:\tj=2; for_range(i,5,--j)"); + for_range(i,5,--j) + { + printf(" [%d]",i); + } + print(""); - printf("\n"); + echo("Nesting of this macro seems to be safe:\tfor_range(i,1,3) for_range(j,3,1)"); + for_range(i,1,3) + { + for_range(j,3,1) + { + printf(" [%d,%d]",i,j); + } + } + print(""); }