<!--
{
  "documentType" : "article",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Int64/Words-swift.struct/Sequence-Implementations",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Sequence Implementations"
}
-->

# Sequence Implementations

## Topics

### Instance Properties

[`var lazy: LazySequence<Self>`](/documentation/Swift/Int64/Words-swift.struct/lazy)

A sequence containing the same elements as this sequence,
but on which some operations, such as `map` and `filter`, are
implemented lazily.

### Instance Methods

[`func allSatisfy((Self.Element) throws -> Bool) rethrows -> Bool`](/documentation/Swift/Int64/Words-swift.struct/allSatisfy(_:))

Returns a Boolean value indicating whether every element of a sequence
satisfies a given predicate.

[`func compactMap<ElementOfResult>((Self.Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult]`](/documentation/Swift/Int64/Words-swift.struct/compactMap(_:))

Returns an array containing the non-`nil` results of calling the given
transformation with each element of this sequence.

[`func contains(Self.Element) -> Bool`](/documentation/Swift/Int64/Words-swift.struct/contains(_:))

Returns a Boolean value indicating whether the sequence contains the
given element.

[`func contains(where: (Self.Element) throws -> Bool) rethrows -> Bool`](/documentation/Swift/Int64/Words-swift.struct/contains(where:))

Returns a Boolean value indicating whether the sequence contains an
element that satisfies the given predicate.

[`func count<E>(where: (Self.Element) throws(E) -> Bool) throws(E) -> Int`](/documentation/Swift/Int64/Words-swift.struct/count(where:))

Returns the number of elements in the sequence that satisfy the given
predicate.

[`func elementsEqual<OtherSequence>(OtherSequence) -> Bool`](/documentation/Swift/Int64/Words-swift.struct/elementsEqual(_:))

Returns a Boolean value indicating whether this sequence and another
sequence contain the same elements in the same order.

[`func elementsEqual<OtherSequence>(OtherSequence, by: (Self.Element, OtherSequence.Element) throws -> Bool) rethrows -> Bool`](/documentation/Swift/Int64/Words-swift.struct/elementsEqual(_:by:))

Returns a Boolean value indicating whether this sequence and another
sequence contain equivalent elements in the same order, using the given
predicate as the equivalence test.

[`func enumerated() -> EnumeratedSequence<Self>`](/documentation/Swift/Int64/Words-swift.struct/enumerated())

Returns a sequence of pairs (*n*, *x*), where *n* represents a
consecutive integer starting at zero and *x* represents an element of
the sequence.

[`func filter<E>((Self.Element) throws(E) -> Bool) throws(E) -> [Self.Element]`](/documentation/Swift/Int64/Words-swift.struct/filter(_:))

Returns an array containing, in order, the elements of the sequence
that satisfy the given predicate.

[`func first(where: (Self.Element) throws -> Bool) rethrows -> Self.Element?`](/documentation/Swift/Int64/Words-swift.struct/first(where:))

Returns the first element of the sequence that satisfies the given
predicate.

[`func flatMap<ElementOfResult>((Self.Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult]`](/documentation/Swift/Int64/Words-swift.struct/flatMap(_:)-5ogxw)

[`func flatMap<SegmentOfResult>((Self.Element) throws -> SegmentOfResult) rethrows -> [SegmentOfResult.Element]`](/documentation/Swift/Int64/Words-swift.struct/flatMap(_:)-8dp2z)

Returns an array containing the concatenated results of calling the
given transformation with each element of this sequence.

[`func forEach((Self.Element) throws -> Void) rethrows`](/documentation/Swift/Int64/Words-swift.struct/forEach(_:))

Calls the given closure on each element in the sequence in the same order
as a `for`-`in` loop.

[`func lexicographicallyPrecedes<OtherSequence>(OtherSequence) -> Bool`](/documentation/Swift/Int64/Words-swift.struct/lexicographicallyPrecedes(_:))

Returns a Boolean value indicating whether the sequence precedes another
sequence in a lexicographical (dictionary) ordering, using the
less-than operator (`<`) to compare elements.

[`func lexicographicallyPrecedes<OtherSequence>(OtherSequence, by: (Self.Element, Self.Element) throws -> Bool) rethrows -> Bool`](/documentation/Swift/Int64/Words-swift.struct/lexicographicallyPrecedes(_:by:))

Returns a Boolean value indicating whether the sequence precedes another
sequence in a lexicographical (dictionary) ordering, using the given
predicate to compare elements.

[`func map<T, E>((Self.Element) throws(E) -> T) throws(E) -> [T]`](/documentation/Swift/Int64/Words-swift.struct/map(_:)-5qll5)

Returns an array containing the results of mapping the given closure
over the sequence’s elements.

[`func max() -> Self.Element?`](/documentation/Swift/Int64/Words-swift.struct/max())

Returns the maximum element in the sequence.

[`func max(by: (Self.Element, Self.Element) throws -> Bool) rethrows -> Self.Element?`](/documentation/Swift/Int64/Words-swift.struct/max(by:))

Returns the maximum element in the sequence, using the given predicate
as the comparison between elements.

[`func min() -> Self.Element?`](/documentation/Swift/Int64/Words-swift.struct/min())

Returns the minimum element in the sequence.

[`func min(by: (Self.Element, Self.Element) throws -> Bool) rethrows -> Self.Element?`](/documentation/Swift/Int64/Words-swift.struct/min(by:))

Returns the minimum element in the sequence, using the given predicate as
the comparison between elements.

[`func reduce<Result>(Result, (Result, Self.Element) throws -> Result) rethrows -> Result`](/documentation/Swift/Int64/Words-swift.struct/reduce(_:_:))

Returns the result of combining the elements of the sequence using the
given closure.

[`func reduce<Result>(into: Result, (inout Result, Self.Element) throws -> ()) rethrows -> Result`](/documentation/Swift/Int64/Words-swift.struct/reduce(into:_:))

Returns the result of combining the elements of the sequence using the
given closure.

[`func shuffled() -> [Self.Element]`](/documentation/Swift/Int64/Words-swift.struct/shuffled())

Returns the elements of the sequence, shuffled.

[`func shuffled<T>(using: inout T) -> [Self.Element]`](/documentation/Swift/Int64/Words-swift.struct/shuffled(using:))

Returns the elements of the sequence, shuffled using the given generator
as a source for randomness.

[`func sorted() -> [Self.Element]`](/documentation/Swift/Int64/Words-swift.struct/sorted())

Returns the elements of the sequence, sorted.

[`func sorted(by: (Self.Element, Self.Element) throws -> Bool) rethrows -> [Self.Element]`](/documentation/Swift/Int64/Words-swift.struct/sorted(by:))

Returns the elements of the sequence, sorted using the given predicate as
the comparison between elements.

[`func starts<PossiblePrefix>(with: PossiblePrefix) -> Bool`](/documentation/Swift/Int64/Words-swift.struct/starts(with:))

Returns a Boolean value indicating whether the initial elements of the
sequence are the same as the elements in another sequence.

[`func starts<PossiblePrefix>(with: PossiblePrefix, by: (Self.Element, PossiblePrefix.Element) throws -> Bool) rethrows -> Bool`](/documentation/Swift/Int64/Words-swift.struct/starts(with:by:))

Returns a Boolean value indicating whether the initial elements of the
sequence are equivalent to the elements in another sequence, using
the given predicate as the equivalence test.

[`func withContiguousStorageIfAvailable<R>((UnsafeBufferPointer<Self.Element>) throws -> R) rethrows -> R?`](/documentation/Swift/Int64/Words-swift.struct/withContiguousStorageIfAvailable(_:))

Executes a closure on the sequence’s contiguous storage.

---

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)