anatol
anatol

Reputation: 1760

F#: How to print a matrix?

I'm using Math.Net and trying to create a matrix with a random Gaussian distribution. Then I trying to print the matrix but can't:

Successive arguments should be separated by spaces or tupled, and arguments involving function or method applications should be parenthesized

What I'm doing wrong? Taking a look at examples is misleading me much more.

  printfn "%s" (DenseMatrix.random<float> 1000 50 (Normal(1.0, 100.0))).ToString()

Upvotes: 1

Views: 278

Answers (1)

rmunn
rmunn

Reputation: 36708

When the error message says "arguments involving function or method applications should be parenthesized", what that means is that this:

printfn "%s" foo.ToString()

needs to be written as:

printfn "%s" (foo.ToString())

So put an extra set of parentheses around your DenseMatrix value and it should work:

printfn "%s" ((DenseMatrix.random<float> 1000 50 (Normal(1.0, 100.0))).ToString())

The reason for this language design choice gets into advanced topics like currying which you probably don't care about right now, so I'll spare you the long explanation.

Upvotes: 4

Related Questions