mirror of
https://github.com/github/semantic.git
synced 2024-12-27 00:44:57 +03:00
Add a constructor for single-element Streams.
This commit is contained in:
parent
119fdaed78
commit
0c8303f27b
@ -14,6 +14,10 @@ public enum Stream<A>: NilLiteralConvertible, SequenceType {
|
||||
self = f().map { Stream.Cons($0, Memo { Stream(f) }) } ?? Stream.Nil
|
||||
}
|
||||
|
||||
public static func pure(a: A) -> Stream {
|
||||
return .Cons(a, Memo(evaluated: .Nil))
|
||||
}
|
||||
|
||||
public func analysis<B>(@noescape ifCons ifCons: (A, Memo<Stream>) -> B, @noescape ifNil: () -> B) -> B {
|
||||
switch self {
|
||||
case let .Cons(first, rest):
|
||||
|
Loading…
Reference in New Issue
Block a user