Commit Graph
6 Commits
Author SHA1 Message Date
Luchs 6ac4e99b55 test: add string concatenation test for reduce with folding order
Add test cases demonstrating that the reduce function works with string arrays
and concatenation, verifying both with and without initial accumulator values.
The test uses a list of characters ["W", "o", "r", "l", "d"] and the existing
sum function to show that reduce correctly folds strings in order.
2015-01-16 08:48:59 +00:00
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
Luchs a05dc9d733 feat: add test for reduce on empty list expecting runtime error 2015-01-16 08:29:45 +00:00
Luchs fb14301967 feat: implement single-argument reduce with manual iteration and empty-sequence abort
Replace the previous slice-based single-argument reduce implementation with an explicit iterator loop that seeds from the first element. This avoids the out-of-bounds range error on single-element lists and adds a Fiber.abort for empty sequences. Update the test to verify correct behavior for single-element and empty sequences.
2015-01-16 08:24:18 +00:00
Luchs 6cc513f13c docs: add documentation for reduce function variants in core-library 2015-01-15 15:38:11 +00:00
Luchs afa0a0a8e9 feat: add reduce method to Sequence with two overloads and tests
Implement `reduce` on the `Sequence` class in core.wren with two overloads: one taking an initial accumulator and a function, and another using the first element as the initial accumulator. Add three test files covering normal reduction, single-element edge case, and wrong arity error.
2015-01-15 15:29:49 +00:00