mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +03:00
Stream concatenation.
This commit is contained in:
parent
587ffcbb24
commit
b3c0e92d2a
@ -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: ()) {
|
||||
self = .Nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user