[8f34661] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
| 7 | // forctrl.c -- |
---|
| 8 | // |
---|
| 9 | // Author : Peter A. Buhr |
---|
| 10 | // Created On : Wed Aug 8 18:32:59 2018 |
---|
| 11 | // Last Modified By : Peter A. Buhr |
---|
[3de9135] | 12 | // Last Modified On : Thu Aug 16 09:25:47 2018 |
---|
| 13 | // Update Count : 6 |
---|
[8f34661] | 14 | // |
---|
| 15 | |
---|
[3de9135] | 16 | #include <fstream.hfa> |
---|
[8f34661] | 17 | |
---|
| 18 | struct S { int i, j; }; |
---|
| 19 | void ?{}( S & s ) { s.[i, j] = 0; } |
---|
| 20 | void ?{}( S & s, int i ) { s.[i, j] = [i, 0]; } |
---|
| 21 | void ?{}( S & s, int i, int j ) { s.[i, j] = [i, j]; } |
---|
| 22 | void ?{}( S & s, zero_t ) { s.[i, j] = 0; } |
---|
| 23 | void ?{}( S & s, one_t ) { s.[i, j] = 1; } |
---|
| 24 | S ?+?( S t1, S t2 ) { return (S){ t1.i + t2.i, t1.j + t2.j }; } |
---|
| 25 | int ?<?( S t1, S t2 ) { return t1.i < t2.i && t1.j < t2.j; } |
---|
| 26 | S ?=?( S & t1, S t2 ) { t1.i = t2.i; t1.j = t2.j; return t1; } |
---|
| 27 | S ?+=?( S & t1, S t2 ) { t1 = t1 + t2; return t1; } |
---|
| 28 | S ?+=?( S & t1, one_t ) { t1 = t1 + (S){1}; return t1; } |
---|
| 29 | ofstream & ?|?( ofstream & os, S v ) { return os | '(' | v.i | v.j | ')'; } |
---|
| 30 | |
---|
| 31 | int main() { |
---|
| 32 | while () { sout | "empty"; break; } sout | endl; |
---|
| 33 | do { sout | "empty"; break; } while (); sout | endl; |
---|
| 34 | for () { sout | "empty"; break; } sout | endl; |
---|
| 35 | for ( 10 ) { sout | "X"; } sout | endl; |
---|
| 36 | for ( 0.5 ~ 5.5 ) { sout | "Y"; } sout | endl; |
---|
| 37 | for ( 2 ~= 10 ~ 2 ) { sout | "Z"; } sout | endl; |
---|
| 38 | for ( i; 10 ) { sout | i; } sout | endl; |
---|
| 39 | for ( j; 10 ) { sout | j; } sout | endl; |
---|
| 40 | for ( i; 0.5 ~ 5.5 ) { sout | i; } sout | endl; |
---|
| 41 | for ( i; 2 ~= 10 ~ 2 ) { sout | i; } sout | endl; |
---|
| 42 | for ( ui; 2u ~= 10u ~ 2u ) { sout | ui; } sout | endl; |
---|
| 43 | int start = 3, comp = 10, inc = 2; |
---|
| 44 | for ( i; start ~ comp ~ inc + 1 ) { sout | i; } sout | endl; |
---|
| 45 | |
---|
| 46 | for ( S s = (S){0}; s < (S){10,10}; s += (S){1} ) { sout | s; } sout | endl; |
---|
| 47 | // for ( s; (S){10,10} ) { sout | s; } sout | endl; |
---|
| 48 | for ( s; (S){0} ~ (S){10,10} ) { sout | s; } sout | endl; |
---|
| 49 | for ( s; (S){0} ~ (S){10,10} ~ (S){1} ) { sout | s; } sout | endl; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | // Local Variables: // |
---|
| 53 | // tab-width: 4 // |
---|
| 54 | // compile-command: "cfa forctrl.c" // |
---|
| 55 | // End: // |
---|