previous chapterthe pico pagenext chapter


Function definition

Functions can be defined by using the colon to affix a function prescription to a function invocation. A prescription is a valid expression used to specify the future behaviour of the function; the invocation must specify the function name and a parameter list consisting of any number of parameter names separated by comma's and delimited by ordinary parentheses.

name(name,...): expression

The following example is a valid function definition:

f(x,y,z): x*(y+z)

We can easily see that a function named f is introduced featuring three parameters called x, y and z. The prescription states that an application of this function will add the values bound to y and z and return this sum multiplied by the value of x. Pico comes with most of the essential functions already defined; these will be enumerated in later paragraphs. Actually, a function definition introduces a new variable in the current dictionary; instead of a number, fraction or text, a value representing a function (or function for short) is bound to this variable. Functions have no grammatical representations, which is why the print component displays the value of f as follows:

<function f>


previous chapterthe pico pagenext chapter