Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
d5f7522a
Commit
d5f7522a
authored
3 years ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add while loops doc
parent
e7863e89
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!145
git subrepo clone git@gitlab.com:OlMon/org-themes.git packages/org-themes
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc/userdoc.org
+28
-2
28 additions, 2 deletions
doc/userdoc.org
with
28 additions
and
2 deletions
doc/userdoc.org
+
28
−
2
View file @
d5f7522a
...
@@ -1975,9 +1975,35 @@ However, to ease the reading, it is probably better to write
...
@@ -1975,9 +1975,35 @@ However, to ease the reading, it is probably better to write
It gives also
It gives also
#+results: do-while-block
#+results: do-while-block
*** TODO while loops
*** ~while~ loops
The last kind of loops that is allowed in ~pugs~ language is the ~while~
loop.
#+BEGIN_SRC pugs :exports code
while (condition) statement
#+END_SRC
The ~statement~ is either a single instruction or a block of
instructions. The ~condition~ is an expression of boolean value (type
~B~).
This time is the ~condition~ is never satisfied (never ~true~), the
~statment~ is not executed.
An example of the ~while~ loop is the following.
#+NAME: while-block
#+BEGIN_SRC pugs :exports both :results output
let sum:N, sum = 0;
let i:N, i = 1;
while (sum<=10) {
sum += i;
++i;
}
cout << "sum = " << sum << "\n";
#+END_SRC
The result is
#+results: while-block
*** TODO break/continue
** TODO Functions<<functions>>
** TODO Functions<<functions>>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment