From d5f7522aaa69db3fdd13462c1269ebb3e8abf213 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com>
Date: Mon, 30 May 2022 18:36:59 +0200
Subject: [PATCH] Add while loops doc

---
 doc/userdoc.org | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/doc/userdoc.org b/doc/userdoc.org
index fd14d7803..4d8c90f29 100644
--- a/doc/userdoc.org
+++ b/doc/userdoc.org
@@ -1975,9 +1975,35 @@ However, to ease the reading, it is probably better to write
 It gives also
 #+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>>
 
-- 
GitLab