26 lines
512 B
Plaintext
26 lines
512 B
Plaintext
sequence ctable = {}
|
|
|
|
function compose(integer f, integer g)
|
|
ctable = append(ctable,{f,g})
|
|
return length(ctable)
|
|
end function
|
|
|
|
function call_composite(integer f, atom x)
|
|
integer g
|
|
{f,g} = ctable[f]
|
|
return call_func(f,{call_func(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(routine_id("halve"),routine_id("plus1"))
|
|
|
|
?call_composite(m,1) -- displays 1
|
|
?call_composite(m,4) -- displays 2.5
|