author | Christian Urban <christian.urban@kcl.ac.uk> |
Fri, 28 Oct 2022 09:08:13 +0100 | |
changeset 893 | 54a483a33763 |
parent 869 | 81ee93b87258 |
permissions | -rw-r--r-- |
864 | 1 |
val Max : Int = 10; |
2 |
||
3 |
def sqr(x: Int) : Int = x * x; |
|
4 |
||
5 |
def all(n: Int) : Void = { |
|
6 |
if n <= Max |
|
7 |
then { print_int(sqr(n)) ; new_line(); all(n + 1) } |
|
8 |
else skip() |
|
9 |
}; |
|
10 |
||
869
81ee93b87258
changed os-lib as a replacement for ammonite-ops
Christian Urban <christian.urban@kcl.ac.uk>
parents:
864
diff
changeset
|
11 |
{ |
81ee93b87258
changed os-lib as a replacement for ammonite-ops
Christian Urban <christian.urban@kcl.ac.uk>
parents:
864
diff
changeset
|
12 |
print_string("Squares"); |
81ee93b87258
changed os-lib as a replacement for ammonite-ops
Christian Urban <christian.urban@kcl.ac.uk>
parents:
864
diff
changeset
|
13 |
new_line(); |
81ee93b87258
changed os-lib as a replacement for ammonite-ops
Christian Urban <christian.urban@kcl.ac.uk>
parents:
864
diff
changeset
|
14 |
all(0) |
81ee93b87258
changed os-lib as a replacement for ammonite-ops
Christian Urban <christian.urban@kcl.ac.uk>
parents:
864
diff
changeset
|
15 |
} |