机器学习新手:如何存储 a* a* a* 类型的返回值
我有一个返回 int*int 的程序
(用于说明目的的示例): fun program(a,b) = (1,2)
我想做一些类似的事情:
趣味节目(a,b)
如果 a = 0 则 (1,2)
否则
val x,y = 程序(a-1,b)
返回(x-1,y)
基本上,我想操作返回的元组,然后返回它的修改。
谢谢
I have a program that returns int*int
(Example for illustration purposes):
fun program(a,b) = (1,2)
I want to do something along the lines:
fun program(a,b)
if a = 0 then (1,2)
else
val x,y = program(a-1,b)
return (x-1, y)
Basically, I want to manipulate the tuple that is returned, and then return a modification of it.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我还想建议,虽然您需要返回类型
t : int * int
,但您至少curry< /strong> 函数的输入来自:int * int = int -> int
。如果您需要将其转回原处,您可以随时取消咖喱。我建议将该函数编写为:该函数的类型是:
int ->整数-> (整数*整数)
I'd also like to suggest that while you need to return a type
t : int * int
, you can atleast curry the inputs to your function from :int * int = int -> int
. If you need to turn this back, you can always uncurry. I'd suggest writing the function as :The type of this function is :
int -> int -> (int * int)
这几乎与您编写的完全一样,只是您的语法有点偏离:
具体来说:
fun f args = body
定义 - 您遗漏了=
。let val foo = bar in baz end
绑定。This works almost exactly as you wrote it, except that your syntax is a bit off:
Specifically:
fun f args = body
- you left out the=
.let val foo = bar in baz end
.