Created
May 30, 2019 00:39
-
-
Save Qata/8cada0d09b667748a0c8e5ed61e45a04 to your computer and use it in GitHub Desktop.
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
public extension LazySequence { | |
/// Create an infinitely repeating sequence of values identical to `value`. | |
/// | |
/// let names = ["Jane", "Jack", "Gwynne", "Micky"] | |
/// let hellos = LazySequence(repeating: "Hello") | |
/// let g = zip(hellos, names).map { "\($0), \($1)" } | |
/// g == ["Hello, Jane", "Hello, Jack", "Hello, Gwynne", "Hello, Micky"] | |
/// | |
/// - Parameter repeating: `repeating` takes the element to be repeated. | |
/// - Returns: An infinite lazy sequence of `value`. | |
init<T>(repeating value: T) where Base == AnyIterator<T> { | |
self = AnyIterator { value }.lazy | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment