820
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1 |
val Max : Int = 10;
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
3 |
def sqr(x: Int) : Int = x * x;
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
4 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
def all(n: Int) : Void = {
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
6 |
if n <= Max
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
7 |
then print_int(sqr(n)) ; all(n + 1)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
8 |
else skip()
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
9 |
};
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
10 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
11 |
all(0)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
12 |
|