previous chapterthe pico pagenext chapter


Table definition

Pico allows values to be combined into tables. Tables -very similar to vectors from mathematics- are defined by using an indexed invocation:

name[expression]: expression

Tables are named and this name is used to define a variable in the current dictionary. The square brackets are a hint needed by Pico to indicate that a table is considered; they delimit a size. Any expression with a non-negative number value can be used as a valid table size. The freshly defined variable will be bound to a table, that is a sequence of value slots. The number of slots is defined by the indicated size (and might be zero). Each slot can hold an arbitrary value, which is initially set to a newly computed value of the expression to the right of the colon. Therefore, the following expression:

T[10]: 0

introduces a variable named T bound to a table containing ten slots each containing the value 0. The following transcript illustrates a more sophisticated use of tables:

Note that the value of a table definition is the table itself; its slots are displayed by the print component as a list delimited by square brackets and separated by commaÌs. Also note that the slot values of P are computed from left to right using the expression n:=n-1, starting with the value 5 for n.


previous chapterthe pico pagenext chapter