/* 3. C<<1 iterators - updated 2008-01-07 by xCh. */
/* ------------------------------------------------------------------- */
#define loop while(TRUE)
-#define repeat(N) _NEW_I for_range(_I,1,N)
-#define for_range(VAR,FROM,TO) for(VAR=FROM; FROM<=TO?VAR<=TO:VAR>=TO; FROM<=TO?VAR++:VAR--)
+#define repeat(N) if(N>0) _NEW_I for_range(_I,1,N)
+#define for_range(VAR,FROM,TO) for( VAR=FROM ; FROM<=TO?(VAR<=TO):(VAR>=TO) ; FROM<=TO?(VAR++):(VAR--))
#define for_each(A,B) for(A=B; A; A=A->_next)
#define for_search(A,B,C) for_each(A,B) if(C)
/*to do: #define for_file_lines(STR,F) _NEW_F for() */
--- /dev/null
+#include "cll1.h"
+
+program
+{
+ int i;
+
+ printf("for_range(i,0,1)");
+ for_range(i,0,1) printf(" [%d]",i);
+
+ printf("\nfor_range(i,1,0)");
+ for_range(i,1,0) printf(" [%d]",i);
+
+ printf("\nfor_range(i,1,1)");
+ for_range(i,1,1) printf(" [%d]",i);
+
+ printf("\nfor_range(i,1,5)");
+ for_range(i,1,5) printf(" [%d]",i);
+
+ printf("\nfor_range(i,5,1)");
+ for_range(i,5,1) printf(" [%d]",i);
+
+ printf("\n");
+}
--- /dev/null
+#include "cll1.h"
+
+program
+{
+ const int kmen=28;
+ int jehlici=0,vetev=0,stromecek=2;
+
+ while(jehlici<=kmen)
+ {
+ repeat(kmen-jehlici) printf(" ");
+ printf("/");
+ repeat(jehlici<<1) if (jehlici<kmen && vetev<stromecek-1) then printf(" "); else printf("_");
+ printf("\\\n");
+ if(++vetev<stromecek) then jehlici++; else jehlici-=vetev>>1,vetev=0,stromecek++;
+ }
+ repeat(kmen) printf(" ");
+ printf("||\n");
+}