0001 extension LazySequenceType { 0002 0003 @warn_unused_result 0004 public func flatMap<T>(transform: Elements.Generator.Element -> T?) 0005 -> LazyMapSequence<LazyFilterSequence<LazyMapSequence<Elements, T?>>, T> { 0006 return self 0007 .map(transform) 0008 .filter { opt in opt != nil } 0009 .map { notNil in notNil! } 0010 } 0011 } 0012 0013 extension LazyCollectionType { 0014 0015 @warn_unused_result 0016 public func flatMap<T>(transform: Elements.Generator.Element -> T?) 0017 -> LazyMapCollection<LazyFilterCollection<LazyMapCollection<Elements, T?>>, T> { 0018 return self 0019 .map(transform) 0020 .filter { opt in opt != nil } 0021 .map { notNil in notNil! } 0022 } 0023 }