diff options
Diffstat (limited to 'chapter17/README.md')
| -rw-r--r-- | chapter17/README.md | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/chapter17/README.md b/chapter17/README.md index 95cc397e..b9733873 100644 --- a/chapter17/README.md +++ b/chapter17/README.md @@ -108,21 +108,39 @@ Allow `pred ? e_true : e_false`. Also allow `pred ? e_true`, where the false re is the zero type version of the true result. +## For Loops +Allow C/C++ style `for` loops: + +`for( init; test; next ) body` + +```cpp +int sum=0; +for( int i=0; i<arg; i++ ) + sum = sum + i; +return sum; +``` + +Any of `init`, `test` and `next` can be empty. +`init` allows for declaration of a new variable, with scope limited to the `for` expression. + +```cpp +int sum=0; +for( int i=0; i<arg; i++ ) + sum = sum + i; +return sum; +``` -C++-style for-loop for-interator -trinary switch - # Chapter 18: Functions Some thinking on function syntax: |
