RosettaCodeData/Task/Function-composition/Elena/function-composition.elena

15 lines
196 B
Text
Raw Permalink Normal View History

2019-09-12 10:33:56 -07:00
import extensions;
2017-09-23 10:01:46 +02:00
2019-09-12 10:33:56 -07:00
extension op : Func1
2017-09-23 10:01:46 +02:00
{
2019-09-12 10:33:56 -07:00
compose(Func1 f)
= (x => self(f(x)));
2017-09-23 10:01:46 +02:00
}
2019-09-12 10:33:56 -07:00
public program()
{
var fg := (x => x + 1).compose:(x => x * x);
2017-09-23 10:01:46 +02:00
2019-09-12 10:33:56 -07:00
console.printLine(fg(3))
}