<commit_before>//===--- FlatMap.swift ----------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

extension LazySequenceProtocol {
  /// Returns the concatenated results of mapping `transform` over
  /// `self`.  Equivalent to 
  ///
  ///     self.map(transform).flatten()
  ///
  /// - Complexity: O(1)
  @warn_unused_result
  public func flatMap<Intermediate: Sequence>(
    transform: (Elements.Iterator.Element)->Intermediate
  ) -> LazySequence<
    FlattenSequence<LazyMapSequence<Elements, Intermediate>>> {
    return self.map(transform).flatten()
  }
}

extension LazyCollectionProtocol {
  /// Returns the concatenated results of mapping `transform` over
  /// `self`.  Equivalent to 
  ///
  ///     self.map(transform).flatten()
  ///
  /// - Complexity: O(1)
  @warn_unused_result
  public func flatMap<Intermediate: Collection>(
    transform: (Elements.Iterator.Element)->Intermediate
  ) -> LazyCollection<
    FlattenCollection<
      LazyMapCollection<Elements, Intermediate>>
  > {
    return self.map(transform).flatten()
  }
}

extension LazyCollectionProtocol where Elements.Index : BidirectionalIndex
{
  /// Returns the concatenated results of mapping `transform` over
  /// `self`.  Equivalent to 
  ///
  ///     self.map(transform).flatten()
  ///
  /// - Complexity: O(1)
  @warn_unused_result
  public func flatMap<
    Intermediate: Collection
    where Intermediate.Index : BidirectionalIndex
  >(
    transform: (Elements.Iterator.Element)->Intermediate
  ) -> LazyCollection<
    FlattenBidirectionalCollection<
      LazyMapCollection<Elements, Intermediate>
  >> {
    return self.map(transform).flatten()
  }
}<commit_msg>flatMap(): generic type parameter `Intermediate`  => `SegmentOfResult`<commit_after>//===--- FlatMap.swift ----------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

extension LazySequenceProtocol {
  /// Returns the concatenated results of mapping `transform` over
  /// `self`.  Equivalent to 
  ///
  ///     self.map(transform).flatten()
  ///
  /// - Complexity: O(1)
  @warn_unused_result
  public func flatMap<SegmentOfResult : Sequence>(
    transform: (Elements.Iterator.Element)->SegmentOfResult
  ) -> LazySequence<
    FlattenSequence<LazyMapSequence<Elements, SegmentOfResult>>> {
    return self.map(transform).flatten()
  }
}

extension LazyCollectionProtocol {
  /// Returns the concatenated results of mapping `transform` over
  /// `self`.  Equivalent to 
  ///
  ///     self.map(transform).flatten()
  ///
  /// - Complexity: O(1)
  @warn_unused_result
  public func flatMap<SegmentOfResult : Collection>(
    transform: (Elements.Iterator.Element)->SegmentOfResult
  ) -> LazyCollection<
    FlattenCollection<
      LazyMapCollection<Elements, SegmentOfResult>>
  > {
    return self.map(transform).flatten()
  }
}

extension LazyCollectionProtocol where Elements.Index : BidirectionalIndex
{
  /// Returns the concatenated results of mapping `transform` over
  /// `self`.  Equivalent to 
  ///
  ///     self.map(transform).flatten()
  ///
  /// - Complexity: O(1)
  @warn_unused_result
  public func flatMap<
    SegmentOfResult : Collection
    where SegmentOfResult.Index : BidirectionalIndex
  >(
    transform: (Elements.Iterator.Element)->SegmentOfResult
  ) -> LazyCollection<
    FlattenBidirectionalCollection<
      LazyMapCollection<Elements, SegmentOfResult>
  >> {
    return self.map(transform).flatten()
  }
}
{'fraction_non_alphanumeric': 0.18162692847124826, 'fraction_numerical': 0.006077606358111267, 'mean_word_length': 2.5927791771620488, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2625819', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1163, 'n_words': 285}