Created
July 3, 2015 17:30
-
-
Save oisdk/5b367748dec9844576ee 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
private extension GeneratorType { | |
mutating func any(@noescape pred: Element -> Bool) -> Bool { | |
return next().map { el in pred(el) || any(pred) } ?? false | |
} | |
mutating func all(@noescape pred: Element -> Bool) -> Bool { | |
return next().map { el in pred(el) && all(pred) } ?? true | |
} | |
} | |
public extension SequenceType { | |
func any(@noescape predicate: Generator.Element -> Bool) -> Bool { | |
var g = self.generate() | |
return g.any(predicate) | |
} | |
func all(@noescape predicate: Generator.Element -> Bool) -> Bool { | |
var g = self.generate() | |
return g.all(predicate) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment