Files
wren/test/range/reduce.wren
T
Luchs b25c181b7b feat: add reduce test for range covering sum and min with initial value
Add a new test file `test/range/reduce.wren` that validates the `reduce` method on numeric ranges. The test exercises two cases: summing integers 1 through 10 (expecting 55) and finding the minimum value with an initial accumulator of 100 (expecting 1).
2015-01-16 08:33:23 +00:00

5 lines
137 B
Plaintext

var range = 1..10
IO.print(range.reduce {|a, b| a + b }) // expect: 55
IO.print(range.reduce(100) {|a, b| a < b ? a : b }) // expect: 1