F# 如何打印fn int*int*int类型
如何在不创建其他函数的情况下打印fn此类型?您可以使用格式化程序%A打印任何类型: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
> (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如果在某个大型递归数据结构上尝试,则速度会很慢。。因为它使用反射来导航数据结构并打印结果