我需要创建一个函数,将两个由浮点数组成的元组相加,并返回一个由两个浮点数组成的元组。
let add a b =
fst a + fst b, snd a + snd b
Run Code Online (Sandbox Code Playgroud)
给我这个回报:
val add : int * int -> int * int -> int * int
Run Code Online (Sandbox Code Playgroud)
但如果我尝试:
let add (a:float) (b:float) =
fst a + fst b, snd a + snd b
Run Code Online (Sandbox Code Playgroud)
我明白了:
This expression was expected to have type
''a * 'd'
but here has type
'float'
Run Code Online (Sandbox Code Playgroud)
我该如何获得以下回报?
val add : float * float -> float * float -> float * float
Run Code Online (Sandbox Code Playgroud)