Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
F# 如何打印fn int*int*int类型_F# - Fatal编程技术网

F# 如何打印fn int*int*int类型

F# 如何打印fn int*int*int类型,f#,F#,如何在不创建其他函数的情况下打印fn此类型?您可以使用格式化程序%A打印任何类型: > (1, 2, 3);; val it : int * int * int = (1, 2, 3) > printfn "%d" (1, 2 ,3);; printfn "%d" (1, 2 ,3);; --------------^^^^^^^ stdin(2,15): error FS0001: The type '('a * 'b * 'c)' is not compatible

如何在不创建其他函数的情况下打印fn此类型?

您可以使用格式化程序%A打印任何类型:

> (1, 2, 3);;
val it : int * int * int = (1, 2, 3)

> printfn "%d" (1, 2 ,3);;

  printfn "%d" (1, 2 ,3);;
  --------------^^^^^^^

stdin(2,15): error FS0001: The type '('a * 'b * 'c)' is not compatible with any of the types byte,int16,int32,int64,sbyt
e,uint16,uint32,uint64,nativeint,unativeint, arising from the use of a printf-style format string

否则,您将需要解压缩元组以打印它,因为没有特定于元组的格式化程序。

您可以使用格式化程序%A打印任何类型:

> (1, 2, 3);;
val it : int * int * int = (1, 2, 3)

> printfn "%d" (1, 2 ,3);;

  printfn "%d" (1, 2 ,3);;
  --------------^^^^^^^

stdin(2,15): error FS0001: The type '('a * 'b * 'c)' is not compatible with any of the types byte,int16,int32,int64,sbyt
e,uint16,uint32,uint64,nativeint,unativeint, arising from the use of a printf-style format string

否则,您将需要解压元组以打印它,因为没有特定于元组的格式化程序。

只需添加,%A,如果您在某个大型递归数据结构上尝试它,则速度会很慢。。由于它使用反射来导航数据结构并打印结果(仅用于添加),%A如果在某个大型递归数据结构上尝试,则速度会很慢。。因为它使用反射来导航数据结构并打印结果