Swift.org Oct 7, 2020

Swift Algorithms Library

Article Summary

Nate Cook from Apple's Swift team just dropped Swift Algorithms, an open-source package that could change how iOS developers write collection code. If you've ever written a gnarly nested loop to chunk data or find permutations, this is for you.

Apple released Swift Algorithms as an official open-source package containing battle-tested sequence and collection algorithms. Think Python's itertools or C++ algorithms library, but designed specifically for Swift's protocol-oriented approach. The package serves as a proving ground for algorithms before they graduate into the Swift standard library.

Key Takeaways

Critical Insight

Swift Algorithms gives iOS developers a curated toolkit of collection operations that improve code correctness while providing a faster path for new algorithms to reach the standard library.

The chunked(by:) examples alone will make you rethink how you've been processing arrays, and there are nine other algorithm families worth exploring.

Recent from Swift.org

Related Articles