Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
什么可能是函数 foo,它有一个类型
’a * ’a -> int
在机器学习中。即具有以下输出类型的函数
这似乎是功课,所以我只给你一个部分解决方案和一些提示。您想要的类型是 a 'a * 'a -> int,因此合适函数的骨架可能是这样的(我假设您使用的是标准 ML):
'a * 'a -> int
fun foo(x, y) = ???
???需要满足两个要求:它必须包含一个强制x和y具有相同类型的表达式,并且它必须返回一个整数。后者应该不难。对于前者,SML 中有很多可能性,例如,将它们放在同一个列表中,或者从相同iforcase或的分支返回它们handle。
???
x
y
if
case
handle