Skip to content
Snippets Groups Projects
Commit 37319592 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add break and continue doc

parent d5f7522a
No related branches found
No related tags found
1 merge request!145git subrepo clone git@gitlab.com:OlMon/org-themes.git packages/org-themes
...@@ -2005,6 +2005,48 @@ The result is ...@@ -2005,6 +2005,48 @@ The result is
#+results: while-block #+results: while-block
*** ~break~ and ~continue~ keywords.
These *keywords* are used to control loops behavior from enclosed loop
statements. They follow their ~C++~ counterparts.
- The ~continue~ keyword is used to skip the instructions that follow in
the loop statement and continue the loop.
- The ~break~ keyword is leaves the current loop.
An example of use of the ~continue~ keyword is
#+NAME: nested-continue
#+BEGIN_SRC pugs :exports both :results output
for (let i:N, i = 0; i < 5; ++i) {
cout << i << ": ";
for (let j:N, j=0; j < 5; ++j) {
if (j<i) continue;
cout << j << " ";
}
cout << "\n";
}
#+END_SRC
The result is
#+results: nested-continue
Replacing the ~continue~ keyword by a ~break~
#+NAME: nested-break
#+BEGIN_SRC pugs :exports both :results output
for (let i:N, i = 0; i < 5; ++i) {
cout << i << ": ";
for (let j:N, j=0; j < 5; ++j) {
if (j>i) break;
cout << j << " ";
}
cout << "\n";
}
#+END_SRC
changes the output to
#+results: nested-break
Obviously the behavior is the same using ~do...while~ or ~while~ loops.
** TODO Functions<<functions>> ** TODO Functions<<functions>>
*** Pure functions *** Pure functions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment