previous chapterthe pico pagenext chapter


Function assignment

Any previously defined function is accessible via the variable that its name refers to. This variable -and any other variable for that matter- can be changed through ordinary variable assignment or through function assignment:

name(expression,...) := expression

The effect is identical to that of function definition except for the fact that no new variable is introduced. Note that any previous value -function or otherwise- is discarded.

At this stage function assignment is not really an essential feature of Pico. Nevertheless, in order to illustrate future use, the more adventurous reader is invited to examine the following transcript:

Note that the definition of the function q contains a prescription that starts by redefining itself and then applying the new definition of q to the original parameter z (the curly braces and the semicolon serve to group multiple expressions, and will be defined later on). Hence the first application changes the definition of q to:

q(y):= z:=z+y

and therefore returns the value 20. The next two applications q(11) and q(5) however, use this redefined version of q. The interesting part about this example is the use of z as a kind of memory for the function q making it behave like an accumulator.


previous chapterthe pico pagenext chapter