Project

General

Profile

WHILE in Scol » History » Version 3

iri, 09/25/2012 12:00 AM

1 1 iri
h1. WHILE in Scol
2
3
*while* <condition> *do* instructions
4
5
<pre>
6
while <condition> do
7
(
8
	instruction_1;
9
	instruction_2;
10
	instruction_3;
11
	
12
	instruction_n;
13
);
14
</pre>
15
16
If the condition is false at the start, the instructions block is never ran.
17
18
Example :
19
<pre>
20
fun main ()=
21
	_showconsole;
22
	
23
	let 10 -> counter in
24
	while (counter >= 0) do
25
	(
26
		_fooId counter;
27 3 iri
        // do not forget to increase or decrease your counter, otherwise, the loop can become infinite
28 2 iri
		set counter = counter-1
29 1 iri
	);
30
	0;;
31
</pre>
32
	
33
34
License : "CC-BY-SA-2.0":https://creativecommons.org/licenses/by-sa/2.0/
35
Tutorial by iri
36
Updated by /