Skip to content

Conversation

@valeriyvan
Copy link
Contributor

Adds minmax() to Sequence
Adds minIndex(), maxIndex(), minmaxIndices() to Collection
Adds minmax() to SIMDVector
Adds validation tests

Swift evolution proposal will be submitted soon.

Resolves SR-890 and SR-889.

@gribozavr gribozavr added the swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review label Jul 9, 2020
let SequenceAlgorithmTests = TestSuite("SequenceAlgorithm")

SequenceAlgorithmTests.test("[1,2,3,4,5,-9,6,7,8,9,0].min()") {
expectEqual([1,2,3,4,5,-9,6,7,8,9,0].min()!, -9)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use OpaqueValue and MinimalComparableValue instead of integers.

Also, there are already tests for min and max in validation-test/stdlib/SequenceType.swift.gyb. Please add new tests there and follow the existing pattern.

@warn_unqualified_access
public func minmaxIndices(
by areInIncreasingOrder: (Element, Element) throws -> Bool
) rethrows -> (Index, Index)? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better if the elements of the result tuple were labelled? Please discuss this point in the proposal.

elements: test.sequence.enumerated().map {
MinimalComparableValue($1, identity: $0)
})
var maybeResult = s.minmax()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! what about other new APIs?

@shahmishal
Copy link
Member

Please update the base branch to main by Oct 5th otherwise the pull request will be closed automatically.

  • How to change the base branch: (Link)
  • More detail about the branch update: (Link)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review

3 participants