我将尝试创建一个在F#中的函数,其输入为一个二维整数数组(9x9),并打印其内容。下面是我实现的代码:
问题在于 F# 无法自动推断矩阵的类型,并显示以下错误:"The operator 'expr.[idx]' has been used an object of indeterminate type based on information prior to this program point. Consider adding further type constraints"。
我试图在函数定义中使用类型注释,但是我认为我做错了。有什么想法可以解决这个问题吗?
let printMatrix matrix=
for i in 0 .. 8 do
for j in 0 .. 8 do
printf "%d " matrix.[i,j]
printf "\n"
问题在于 F# 无法自动推断矩阵的类型,并显示以下错误:"The operator 'expr.[idx]' has been used an object of indeterminate type based on information prior to this program point. Consider adding further type constraints"。
我试图在函数定义中使用类型注释,但是我认为我做错了。有什么想法可以解决这个问题吗?