User:Coderjoe/Sandbox2
Oz
To be executed in the REPL.
<lang oz>declare
fun {Compose F G} fun {$ X} {F {G X}} end end
fun {Cube X} X*X*X end
fun {CubeRoot X} {Number.pow X 1.0/3.0} end
in
for F in [Float.sin Float.cos Cube] I in [Float.asin Float.acos CubeRoot] do {Show {{Compose I F} 0.5}} end
</lang>
PARI/GP
<lang parigp>compose(f,g)={
x -> f(g(x))
};
fcf()={
my(A,B); A=[x->sin(x), x->cos(x), x->x^2]; B=[x->asin(x), x->acos(x), x->sqrt(x)]; for(i=1,#A, print(compose(A[i],B[i])(.5)) )
};</lang> Usage note: In Pari/GP 2.4.3 the vectors can be written as <lang parigp> A=[sin, cos, x->x^2];
B=[asin, acos, x->sqrt(x)];</lang>