Skip to content

Swift Algorithms 0.2.0

Compare
Choose a tag to compare
@natecook1000 natecook1000 released this 17 May 18:11
· 44 commits to main since this release
e25cf27

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 just SubSequence, 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.