Functions Creating Other Functions Example

Functions can create other functions.

ASSIGN/COMPOSE=FUNCTION((F,G),FUNCTION((X),G(F(X))))
Assigns COMPOSE to be a function that takes two functions as parameters and creates a new function using the two functions.

ASSIGN/ADD2=FUNCTION((X),X+2)
Assigns ADD2 to be a function that adds two to the parameter passed in.

ASSIGN/ADD3=FUNCTION((X),X+3)
Assigns ADD3 to be a function that adds three to the parameter passed in.

ASSIGN/ADD5=COMPOSE(ADD2,ADD3)
Assigns ADD5 to be a function composed of the functions ADD2 and ADD3.

ASSIGN/V5=ADD5(3)
Assigns V5 to have the value V8.