previous chapterthe pico pagenext chapter


Composition function

It is often necessary to assemble multiple expressions into one composite expression, for instance when the prescription for a function definition cannot be stated in one simple expression. Pico provides the function begin as an answer to this need.

As shown by the following transcript, the begin function behaves as follows:

The transcript also illustrates a non-essential syntax for an application of begin:

begin(a,b,...,z)º{a;b;...;z}

The begin arguments are simply delimited by curly braces and separated by semicolons. Practice has shown that large Pico programs become much more readable and easier to debug whenever this alternate representation is used.

The begin function is extremely useful for introducing nested definitions. For instance:

f(x):{a:x;a}

features a variable definition of a that is valid during an application of f and has no effect otherwise. This is an effective means for hiding specifics about the elaboration of a function. In complex problems this enhances the legibility of programs.


previous chapterthe pico pagenext chapter