Skip to content

Swift Algorithms 1.2.0

Latest
Compare
Choose a tag to compare
@natecook1000 natecook1000 released this 15 Nov 04:23
· 6 commits to main since this release

Additions

  • Sequences have new grouped(by:) and keyed(by:) methods, which simplify building dictionaries based on sequence elements: (#197)

    let evensOdds = (1...10).grouped(by: { $0.isMultiple(of: 2) ? "even" : "odd" })
    // ["even": [2, 4, 6, 8, 10], "odd": [1, 3, 5, 7, 9]]
    
    let animals = ["Aardvark", "Alpaca", "Armadillo", "Barracuda", "Buffalo", ...]
    let alphaAnimals = animals.keyed(by: \.first!, resolvingConflictsWith: { _, first, _ in first })
    // ["A": "Aardvark", "B": "Barracuda", ...]
  • The endOfPrefix(while:) and startOfSuffix(while) methods are now public. These methods were previously implementation details of the trimming group of methods. (#211)

Fixes

  • Documentation and performance improvements. (#202, #210)

The 1.2.0 release includes contributions from @amomchilov, @mattyoung, @natecook1000, @stephentyrone, and @ttsugriy.
Thank you!