From MSDN docs, the signature of List.max is:
List.max : 'T list -> 'T (requires comparison)
My questions are:
'T supports comparison operation?requires a keyword to specify type constraints? If yes, what all types of constraints can I specify with it?take a look at this blog from Don Syme: Equality and Comparison Constraints in F#
you can think of those contraints as a form of type-classes light, normaly overriding Equals/GetHashCode and implementing IComparable is sufficient to use it in this cases.
To your questions:
PS: the (requires comparison) is defined by saying <'a when 'a : comparison> in the context of a generic definition like
type MyType<'a when 'a : comparision>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With