Skip to content

Swift Algorithms 0.0.3

Compare
Choose a tag to compare
@natecook1000 natecook1000 released this 26 Feb 20:23
· 81 commits to main since this release
1e761dd

Additions

An exciting group of new algorithms, contributed by the community:

  • trimming(while:) returns a subsequence of a bidirectional collection with the matching elements removed from the start and end. (#4)
  • min(ofCount:) and max(ofCount:) find the smallest or largest elements in a collection. (#9, #77)
  • windows(ofCount:) lets you iterate over all the overlapping subsequences of a particular length. (#20)
  • striding(by:) iterates over every nth element of a sequence or collection. (#24)
  • interspersed(with:) places a new element between every pair of elements in a sequence or collection. (#35)
  • chunks(ofCount:) breaks a collection into subsequences of the given number of elements. (#54)
  • suffix(while:) matches the standard library's prefix(while:), by returning the suffix of all matching elements from a bidirectional collection. (#65)
  • Variations of combinations(ofCount:) and permutations(ofCount:) that take a range expression as a parameter, returning combinations and permutations of multiple lengths. (#51, #56)

Changes

  • The LazyChunked type now precomputes its startIndex, making performance more predictable when using the collection.

Fixes

  • randomSample(count:) no longer traps in rare circumstances.
  • Index calculations have been improved in a variety of collection wrappers.
  • A variety of documentation improvements and corrections.