Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I agree that matrix should be mainly used when working with numbers. The standard non-generic matrix type (which you can create using the <code>matrix</code> function) works with numbers of type <code>float</code>. If you want to work with other numeric types, you can use <code>Matrix.Generic</code> module, which contains functionality for working with generic matrices (containing any types).</p> <p>You can use generic matrix for storing tuples as well (if you want). A generic matrix can be created using the <code>ofList</code> function. You can also define a function for this to get a nicer syntax:</p> <pre><code>let anymatrix = Matrix.Generic.ofList let B = anymatrix [ [ [1,2]; [3,4] ]; [ [7,8]; [5,6] ] ] </code></pre> <p>To work with generic matrices, you can use the <code>Matrix.Generic</code> module: </p> <pre><code>let Bt = Matrix.Generic.transpose B </code></pre> <p>Typically, you'll use matrices only with numeric types, because many of the operations require some arithmetics in order to work. This will work for all basic numeric types (such as <code>int</code>) and you can also provide arithmetics for your own type using <code>GlobalAssociations</code> <a href="https://stackoverflow.com/questions/2225949/does-f-have-generic-arithmetic-support">discussed here</a>.</p> <p>However, if you want to simply store some values then there are other (more suitable) data types. You can also use <code>Array2D</code> which represents a mutable two-dimensional array.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload