RosettaCodeData/Task/Catamorphism/WDTE/catamorphism.wdte
2023-07-01 13:44:08 -04:00

13 lines
451 B
WDTE

let a => import 'arrays';
let s => import 'stream';
let str => import 'strings';
# Sum of [1, 10]:
let nums => [1; 2; 3; 4; 5; 6; 7; 8; 9; 10];
a.stream nums -> s.reduce 0 + -- io.writeln io.stdout;
# As an alternative to an array, a range stream can be used. Here's the product of [1, 11):
s.range 1 11 -> s.reduce 1 * -- io.writeln io.stdout;
# And here's a concatenation:
s.range 1 11 -> s.reduce '' (str.format '{}{}') -- io.writeln io.stdout;