How to pass two dimensional array to a function in F#? -


i trying create function in f# takes input 2 dimensional array of integers (9 9), , prints content afterwards. following code shows have done :

let printmatrix matrix=     in 0 .. 8         j in 0 .. 8             printf "%d " matrix.[i,j]         printf "\n" 

the problem f# not automatically infer type of matrix, , gives me following error: "the operator 'expr.[idx]' has been used object of indeterminate type based on information prior program point. consider adding further type constraints".

i tried use type annotation in definition of function, think did wrong. idea how can overcome issue?

change

let printmatrix (matrix:int [,])=     in 0 .. 8         j in 0 .. 8             printf "%d " matrix.[i,j]         printf "\n" 

this due how f# type infrence algorithm works


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -