In the sequence of tuples can you find one of the following criteria?

For example, I would like to find a tuple with a minimum date. I tried this

let dateRange2 (prices: seq<System.DateTime * float>) =
    let tupleWithMinDate = prices |> Seq.min(fun (date, _) -> date)
    tupleWithMinDate

Get the red squiggly under the entire right of the conveyor operator. He says: “Type” (seq <System.DateTime * float> → 'a)' does not support the 'comparison' constraint. For example, it does not support the System.IComparable interface

Not sure if returning a typical type is part of the problem - I assumed that Seq.min will know that it returns the type from which the sequence is executed.

+3
source share
2 answers
let dateRange2 (prices: seq<System.DateTime * float>) = prices |> Seq.minBy fst
+10
source

Seq.min takes a sequence as its first (and only) argument, not a function.

Seq.minBy.

+7

Source: https://habr.com/ru/post/1767938/


All Articles