25 lines
476 B
Text
25 lines
476 B
Text
sequence ctable = {}
|
|
|
|
function compose(integer f, g)
|
|
ctable = append(ctable,{f,g})
|
|
integer cdx = length(ctable)
|
|
return cdx
|
|
end function
|
|
|
|
function call_composite(integer cdx, atom x)
|
|
integer {f,g} = ctable[cdx]
|
|
return f(g(x))
|
|
end function
|
|
|
|
function plus1(atom x)
|
|
return x+1
|
|
end function
|
|
|
|
function halve(atom x)
|
|
return x/2
|
|
end function
|
|
|
|
constant m = compose(halve,plus1)
|
|
|
|
?call_composite(m,1) -- displays 1
|
|
?call_composite(m,4) -- displays 2.5
|