RosettaCodeData/Task/First-class-functions/Elena/first-class-functions.elena

20 lines
464 B
Plaintext

import system'routines;
import system'math;
import extensions'routines;
import extensions'math;
extension op
{
compose(f,g)
= f(g(self));
}
public program()
{
var fs := new object[]{ mssgconst sin<mathOp>[1], mssgconst cos<mathOp>[1], (x => power(x, 3.0r)) };
var gs := new object[]{ mssgconst arcsin<mathOp>[1], mssgconst arccos<mathOp>[1], (x => power(x, 1.0r / 3)) };
fs.zipBy(gs, (f,g => 0.5r.compose(f,g)))
.forEach(PrintingLn)
}