The PascaLIGO while loop should look familiar to users of imperative languages.
While loops are of the form `while <condition clause> <block>`, and evaluate
their associated block until the condition evaluates to false.
> ⚠️ The current PascaLIGO while loop has semantics that have diverged from other LIGO syntaxes. The goal of LIGO is that the various syntaxes express the same semantics, so this will be corrected in future versions. For details on how loops will likely work after refactoring, see the CameLIGO tab of this example.
```pascaligo
function while_sum (var n : nat) : nat is block {
var i : nat := 0n ;
var r : nat := 0n ;
while i <nblock{
i := i + 1n;
r := r + i;
}
} with r
```
<!--CameLIGO-->
`Loop.fold_while` is a fold operation that takes an initial value of a certain type
and then iterates on it until a condition is reached. The auxillary function
that does the fold returns either boolean true or boolean false to indicate
whether the fold should continue or not. The initial value must match the input
parameter of the auxillary function, and the auxillary should return type `(bool * input)`.