RosettaCodeData/Task/Partial-function-application/Elena/partial-function-application.elena

19 lines
474 B
Text
Raw Permalink Normal View History

2019-09-12 10:33:56 -07:00
import system'collections;
import system'routines;
import extensions;
2017-09-23 10:01:46 +02:00
2019-09-12 10:33:56 -07:00
public program()
{
var partial := (afs,af => (s => afs(af, s)));
2017-09-23 10:01:46 +02:00
2019-09-12 10:33:56 -07:00
var fs := (f,s => s.selectBy:(x => f(x)).summarize(new ArrayList()).toArray());
var f1 := (x => x * 2);
var f2 := (x => x * x);
2017-09-23 10:01:46 +02:00
2019-09-12 10:33:56 -07:00
var fsf1 := partial(fs, f1);
var fsf2 := partial(fs, f2);
2017-09-23 10:01:46 +02:00
2020-02-17 23:21:07 -08:00
console.printLine(fsf1(new int[]::(2,4,6,8)).toString());
console.printLine(fsf2(new int[]::(2,4,6,8)).toString())
2019-09-12 10:33:56 -07:00
}