mirror of
https://github.com/apple/swift-algorithms
synced 2026-11-23 04:14:22 +00:00
* Finish sub-page documentation updates Some of these pages could use introductions, but the current state is ready for publication. * Add SPI yaml file for building docs
626 B
626 B
Extending
Chain two collections end-to-end, or repeat a collection forever or a specific number of times.
Overview
Chaining two collections
let letters = chain("abcd", "EFGH")
// String(letters) == "abcdEFGH"
for (num, letter) in zip((1...3).cycled(), letters) {
print(num, letter)
}
// 1 a
// 2 b
// 3 c
// 1 d
// 2 E
// 3 F
// 1 G
// 2 H
Topics
Chaining Two Collections
chain(_:_:)
Cycling a Collection
Swift/Collection/cycled()Swift/Collection/cycled(times:)
Supporting Types
Chain2SequenceCycledSequenceCycledTimesCollection