The ALTernative Language
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Spreadsheet

An ALT program can be considered to be a advanced type of spreadsheet. For example, with ALT you can create spreadsheets that have ’typed’ cells, and cells that recursively contain other spreadsheets. In this example we create and edit a simple spreadsheet.

First we define the spreadsheet type _S that only allows cells to contain positive numbers, and has exactly three columns and four rows. Then we create a simple spreadsheet S0 with three columns A,B and C and three rows 1, 2 and 3 (column major ordering). We edit one cell to add a ‘formula’, creating spreadsheet S1. After that we add an extra row to sum columns, creating spreadsheet S2. For every spreadsheet we check whether they still conform to type _S.

Notice that the formulas use advanced relative indexing and scoping. This makes it possible to ‘copy’ such formulas into other spreadsheets at different coordinates (aka relative cell references).