<commit_before># Add `last(where:)` and `lastIndex(where:)` Methods

* Proposal: [SE-0204](0204-add-last-methods.md)
* Author: [<NAME>](https://github.com/natecook1000)
* Status: **Active review (March 29...April 6, 2018)**
* Review manager: [<NAME>](https://github.com/rjmccall)
* Implementation: [apple/swift#13337](https://github.com/apple/swift/pull/13337)
* Bug: [SR-1504](https://bugs.swift.org/browse/SR-1504)

## Introduction

The standard library should include methods for finding the last element in a sequence, and the index of the last element in a collection, that match a given predicate.

* Swift-evolution thread: [\[swift-evolution\] (Draft) Add last(where:) and lastIndex(where:) methods](https://forums.swift.org/t/draft-add-last-where-and-lastindex-where-methods/7131)

## Motivation

The standard library currently has methods that perform a linear search to find an element or the index of an element that matches a predicate:

```swift
let a = [20, 30, 10, 40, 20, 30, 10, 40, 20]
a.first(where: { $0 > 25 })         // 30
a.index(where: { $0 > 25 })         // 1<commit_msg>Extend the review period for SE-0204 per pending revision.<commit_after># Add `last(where:)` and `lastIndex(where:)` Methods

* Proposal: [SE-0204](0204-add-last-methods.md)
* Author: [<NAME>](https://github.com/natecook1000)
* Status: **Active review (March 29...April 10, 2018)**
* Review manager: [<NAME>](https://github.com/rjmccall)
* Implementation: [apple/swift#13337](https://github.com/apple/swift/pull/13337)
* Bug: [SR-1504](https://bugs.swift.org/browse/SR-1504)

## Introduction

The standard library should include methods for finding the last element in a sequence, and the index of the last element in a collection, that match a given predicate.

* Swift-evolution thread: [\[swift-evolution\] (Draft) Add last(where:) and lastIndex(where:) methods](https://forums.swift.org/t/draft-add-last-where-and-lastindex-where-methods/7131)

## Motivation

The standard library currently has methods that perform a linear search to find an element or the index of an element that matches a predicate:

```swift
let a = [20, 30, 10, 40, 20, 30, 10, 40, 20]
a.first(where: { $0 > 25 })         // 30
a.index(where: { $0 > 25 })         // 1
{'fraction_non_alphanumeric': 0.1532976827094474, 'fraction_numerical': 0.06283422459893048, 'mean_word_length': 4.307328605200945, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '909999', 'n_tokens_mistral': 862, 'n_tokens_neox': 708, 'n_words': 225}