This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension Sequence { | |
| var headAndTail: (head: Element, tail: SubSequence)? { | |
| var head: Element? | |
| let tail = drop { | |
| if head == nil { | |
| head = $0 | |
| return true | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let xs = [1, 2, 3, 4, 5] | |
| for (element, index) in zip(xs, xs.indices) { | |
| if index == xs.startIndex { | |
| print("START") | |
| } | |
| print(element) | |
| if index == xs.index(before: xs.endIndex) { |