This is a tuple I have taken
let person = ("Prathap Reddy SV", "Male", 16)
let name = fst person
or
let person = ("Prathap", "Male", 16)
let name = fst person
When I compile this that is showing me the below output
> let person = ("Prathap Reddy SV", "Male", 16)
let name = fst person
let name = fst person
---------------^^^^^^
stdin(152,16): error FS0001: Type mismatch. Expecting a
string * string
but given a
string * string * int
The tuples have differing lengths of 2 and 3
But When I give tuple with two string values it is working fine.
The signature of fst
is ('a * 'b -> 'a)
, that's why you receive the given error.
The function fst
expects a tuple of two elements of whatever types, but you offer it a tuple of three elements. For tuple of three strings the error would be the same: fst ("a","b","c")
will yield
stdin(1,6): error FS0001: Type mismatch. Expecting a
'a * 'b
but given a
'a * 'b * 'c
The tuples have differing lengths of 2 and 3
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