Created
July 11, 2021 21:09
-
-
Save joshuajhomann/2584419abd0d185e9e8ab55c73aa3501 to your computer and use it in GitHub Desktop.
This file contains 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 Collection { | |
func repeatForever() -> UnfoldSequence<Element, Iterator> { | |
sequence(state: makeIterator()) { iterator in | |
iterator.next() ?? { | |
iterator = makeIterator() | |
return iterator.next() | |
}() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment