previous chapterthe pico pagenext chapter


Table functions

Pico provides a number of shortcuts to work with tables. First of all, there exists a native function tab that can be used to create and initialise table values with. It will take any number of arguments, evaluate these and insert the resulting values in the successive slots of a newly created table. In the transcript below, the tab function is used to set up a table holding the text values of the five vowels a, e, i, o and u. The variable t bound to this table is then used in a for loop to decide whether a character o accepted from the keyboard is indeed a vowel. Note that the native function size -introduced in the paragraph on text functions- is extended to return the number of slots in a table.

In analogy to the begin function, a non-essential syntax for an application of tab has been defined:

tab(a,b,...,z) º [a,b,...,z]

The tab arguments are simply delimited by square brackets and separated by comma's, again for reasons of convenience in handling larger programs.


previous chapterthe pico pagenext chapter