13 lines
451 B
WDTE
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;
|