The define keyword is used to introduce new variables.
To define a new function you write this :-
define function F => S enddefine;
However, since functions are so commonly defined there is a slightly shorter and more memorable version. It looks like this :-
function F => S endfunction;
The header part F can be any expression that is
a function call. For example, you can write any of these to define a
function that swaps its two arguments :-
function swap( a, b ) => b, a endfunction;
function a.swap( b ) => b, a endfunction;
# How not to be popular with your co-workers
function (a,(b,())).swap((())) => b, a endfunction;
The effect of a function definition is to introduce a new variable and
to bind it to a function object. You can write these standalone
function objects - or lambda forms - with the fun syntax.
fun Args => S endfun
These function objects can be used to write very concise code. However, that's too advanced a topic for this general introduction. If you want to read more about this style of programming I suggest looking at the Scheme homesite.