RosettaCodeData/Task/Catamorphism/Elena/catamorphism.elena

18 lines
489 B
Text
Raw Permalink Normal View History

2019-09-12 10:33:56 -07:00
import system'collections;
import system'routines;
import extensions;
import extensions'text;
2016-12-05 22:15:40 +01:00
2019-09-12 10:33:56 -07:00
public program()
{
var numbers := new Range(1,10).summarize(new ArrayList());
2016-12-05 22:15:40 +01:00
2019-09-12 10:33:56 -07:00
var summary := numbers.accumulate(new Variable(0), (a,b => a + b));
2016-12-05 22:15:40 +01:00
2019-09-12 10:33:56 -07:00
var product := numbers.accumulate(new Variable(1), (a,b => a * b));
2016-12-05 22:15:40 +01:00
2019-09-12 10:33:56 -07:00
var concatenation := numbers.accumulate(new StringWriter(), (a,b => a.Printable + b.Printable));
2016-12-05 22:15:40 +01:00
2019-09-12 10:33:56 -07:00
console.printLine(summary," ",product," ",concatenation)
}