mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Stream zipping.
This commit is contained in:
parent
00f1daa61a
commit
da12af7313
@ -74,6 +74,14 @@ public enum Stream<A>: NilLiteralConvertible, SequenceType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public func zipWith<S: SequenceType>(sequence: S) -> Stream<(A, S.Generator.Element)> {
|
||||||
|
return Stream<(A, S.Generator.Element)>.unfold((self, Stream<S.Generator.Element>(sequence: sequence))) {
|
||||||
|
guard let (x, xs) = $0.uncons, (y, ys) = $1.uncons else { return nil }
|
||||||
|
return ((x, y), (xs.value, ys.value))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public init(nilLiteral: ()) {
|
public init(nilLiteral: ()) {
|
||||||
self = .Nil
|
self = .Nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user