RosettaCodeData/Task/First-class-functions/Elena/first-class-functions.elena
2020-02-17 23:21:07 -08:00

19 lines
449 B
Text

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::( mssgconst sin<mathOp>[0], mssgconst cos<mathOp>[0], (x => power(x, 3.0r)) );
var gs := new::( mssgconst arcsin<mathOp>[0], mssgconst arccos<mathOp>[0], (x => power(x, 1.0r / 3)) );
fs.zipBy(gs, (f,g => 0.5r.compose(f,g)))
.forEach:printingLn
}