1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 07:55:12 +03:00

Stream concatenation.

This commit is contained in:
Rob Rix 2015-09-17 14:14:01 -04:00
parent 587ffcbb24
commit b3c0e92d2a

View File

@ -41,6 +41,16 @@ public enum Stream<A>: NilLiteralConvertible, SequenceType {
} }
public func concat(other: Stream) -> Stream {
switch self {
case .Nil:
return other
case let .Cons(first, rest):
return .Cons(first, rest.map { $0.concat(other) })
}
}
public init(nilLiteral: ()) { public init(nilLiteral: ()) {
self = .Nil self = .Nil
} }