<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/LazySequenceProtocol/flatMap(_:)-9blrr",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s20LazySequenceProtocolPsE7flatMapys0aB0Vys07FlattenB0Vys0aeB0Vy8ElementsQzqd__GGGqd__7ElementQzcSTRd__lF"
  },
  "title" : "flatMap(_:)"
}
-->

# flatMap(_:)

Returns the concatenated results of mapping the given transformation over
this sequence.

```
func flatMap<SegmentOfResult>(_ transform: @escaping (Self.Elements.Element) -> SegmentOfResult) -> LazySequence<FlattenSequence<LazyMapSequence<Self.Elements, SegmentOfResult>>> where SegmentOfResult : Sequence
```

## Discussion

Use this method to receive a single-level sequence when your
transformation produces a sequence or collection for each element.
Calling `flatMap(_:)` on a sequence `s` is equivalent to calling
`s.map(transform).joined()`.

> Complexity: O(1)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)