Paper sizes

Run this example

# Compute ISO 216 paper sizes for the A series
#
# https://en.wikipedia.org/wiki/ISO_216

struct PaperSize {
    width: Length,
    height: Length,
}

fn paper_size_A(n: Scalar) -> PaperSize =
  if n == 0
    then
      PaperSize {
        width: 841 mm,
        height: 1189 mm
      }
    else
      PaperSize {
        width: floor_in(mm, paper_size_A(n - 1).height / 2),
        height: paper_size_A(n - 1).width,
      }


fn paper_area(size: PaperSize) -> Area =
    size.width * size.height


fn size_as_string(size: PaperSize) = "{size.width:>4} × {size.height:>5}   {paper_area(size) -> cm²:>6.1f}"
fn row(n) = "A{n:<3}   {size_as_string(paper_size_A(n))}"

print("Name    Width     Height        Area  ")
print("----   -------   --------   ----------")
print(join(map(row, range(0, 10)), "\n"))