18 lines
555 B
Plaintext
18 lines
555 B
Plaintext
REM Create some functions for testing:
|
|
DEF FNsqr(a) = SQR(a)
|
|
DEF FNabs(a) = ABS(a)
|
|
|
|
REM Create the function composition:
|
|
SqrAbs = FNcompose(FNsqr(), FNabs())
|
|
|
|
REM Test calling the composition:
|
|
x = -2 : PRINT ; x, FN(SqrAbs)(x)
|
|
END
|
|
|
|
DEF FNcompose(RETURN f%, RETURN g%)
|
|
LOCAL f$, p% : DIM p% 7 : p%!0 = f% : p%!4 = g%
|
|
f$ = "(x)=" + CHR$&A4 + "(&" + STR$~p% + ")(" + \
|
|
\ CHR$&A4 + "(&" + STR$~(p%+4) + ")(x))"
|
|
DIM p% LEN(f$) + 4 : $(p%+4) = f$ : !p% = p%+4
|
|
= p%
|