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

20 lines
449 B
Text
Raw Permalink Normal View History

2019-09-12 10:33:56 -07:00
import system'routines;
import system'math;
import extensions'routines;
2020-02-17 23:21:07 -08:00
import extensions'math;
2016-12-05 22:15:40 +01:00
2017-09-23 10:01:46 +02:00
extension op
2016-12-05 22:15:40 +01:00
{
2019-09-12 10:33:56 -07:00
compose(f,g)
2020-02-17 23:21:07 -08:00
= f(g(self));
2016-12-05 22:15:40 +01:00
}
2019-09-12 10:33:56 -07:00
public program()
{
2020-02-17 23:21:07 -08:00
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)) );
2016-12-05 22:15:40 +01:00
2019-09-12 10:33:56 -07:00
fs.zipBy(gs, (f,g => 0.5r.compose(f,g)))
.forEach:printingLn
}