https://github.com/danramteke/zip2withnilpadding
Zip 2 implementation in Swift 4
https://github.com/danramteke/zip2withnilpadding
sequence swift swift4 zip
Last synced: 3 months ago
JSON representation
Zip 2 implementation in Swift 4
- Host: GitHub
- URL: https://github.com/danramteke/zip2withnilpadding
- Owner: danramteke
- License: mit
- Created: 2017-12-07T20:47:01.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-11T20:34:25.000Z (over 7 years ago)
- Last Synced: 2024-04-23T12:38:57.297Z (about 2 years ago)
- Topics: sequence, swift, swift4, zip
- Language: Swift
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Zip2WithNilPadding
An implementation of `Zip2` for different length Sequences, that fills the missing entries with `nil`.
Updated for Swift 4, based on a solution in this StackOverflow thread: https://stackoverflow.com/questions/25153477/in-swift-i-would-like-to-join-two-sequences-in-to-a-sequence-of-tuples
# Example
```
let first: [String] = ["a", "b", "c", "d"]
let second: [Int] = [1, 2]
let actual = Array(Zip2WithNilPadding(first, second))
# [(Optional("a"), Optional(1)), (Optional("b"), Optional(2)), (Optional("c"), Optional(3))]
```
# License
MIT License