Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
25
Task/Function-composition/Phix/function-composition.phix
Normal file
25
Task/Function-composition/Phix/function-composition.phix
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue