Defining functions in Disco [002J]
We can define our own functions in Disco. First, we give the name of
the function and its type, which will be something like
A -> B where A is the type of the function's inputs,
and B is the type of the outputs. Then we define what output
the function should give for each input.
double : N -> N double(n) = 2nIf we write the above definition of
double in a
.disco file, we can load it at the Disco prompt using the
:load command, then try it on some inputs:
Disco> :load double.disco Loading double.disco... Loaded. Disco> double(2) 4 Disco> double(7) 14