solution/cw5/sqr.fun
author Christian Urban <christian.urban@kcl.ac.uk>
Mon, 24 Jan 2022 00:00:33 +0000
changeset 869 81ee93b87258
parent 864 b5b1bc0a603b
permissions -rw-r--r--
changed os-lib as a replacement for ammonite-ops

val Max : Int = 10;

def sqr(x: Int) : Int = x * x;

def all(n: Int) : Void = {
  if n <= Max
  then { print_int(sqr(n)) ; new_line(); all(n + 1) }
  else skip()
};

{
  print_string("Squares");
  new_line();
  all(0)
}