Swift Algorithms 0.2.0
Additions
Two new additions to the list of algorithms:
adjacentPairs()
lazily iterates over tuples of adjacent elements of a sequence. (#119)minAndMax()
finds both the smallest and largest elements of a sequence in a single pass. (#90)
Changes
-
When calling
chunked(on:)
, the resulting collection has an element type of(Subject, SubSequence)
instead of justSubSequence
, making the subject value available when iterating.let numbers = [5, 6, -3, -9, -11, 2, 7, 6] for (signum, values) in numbers.chunked(on: { $0.signum() }) { print(signum, values) } // 1 [5, 6] // -1 [-3, -9, -11] // 1 [2, 7, 6]
Fixes
- Improvements to the documentation and PR templates.