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

20 lines
449 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::( 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
}