1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Stream.map.

This commit is contained in:
Rob Rix 2015-09-16 12:27:23 -04:00
parent 0dfd3a5ecd
commit 9c47dae557

View File

@ -34,4 +34,9 @@ public enum Stream<A> {
public var isEmpty: Bool {
return uncons == nil
}
public func map<B>(transform: A -> B) -> Stream<B> {
return uncons.map { first, rest in Stream<B>.Cons(transform(first), { rest.map(transform) }) } ?? Stream<B>.Nil
}
}