F# Scribbles

My experiments with F#

Keep input data source as list of list

It is always better to define input data source in list of list for maths calculation. It is easy to convert them into matrix and array 2d. For example,

1
let d1 = [ [1.; 2.]; [3.; 1.]];;

will result

1
val d1 : float list list = [[1.0; 2.0]; [3.0; 1.0]]

This can be easily be converted as Matrix.

1
matrix d1;; // cast it to Matrix

results

1
2
val it : matrix = matrix [[1.0; 2.0]
                          [3.0; 1.0]]

To convert into Array2D by

1
array2D d1;; // cast it to Array2D

results

1
2
val it : float [,] = [[1.0; 2.0]
                      [3.0; 1.0]]