] Label: bool [ ] Label: bool [ ] Label: bool [

how to create a type that contains an array of a specific length, in F#

62 Views Asked by At

I have this type:

[<CLIMutable>]
type MLDataRow =
    {
        [<ColumnName "Label"; LoadColumn(0)>]
        Label: bool
        [<ColumnName "Features"; VectorType(799); LoadColumn(1, 799)>]
        Features: float32 array
    }

    static member Build (label, features: float32 array) = { Label = label; Features = features }

I would like to know how I can create an object where the '799' number is a parameter?

for example:

let a = MLDataRow.Build (10, true, myData)

would be creating an object like:

[<CLIMutable>]
type MLDataRow =
    {
        [<ColumnName "Label"; LoadColumn(0)>]
        Label: bool
        [<ColumnName "Features"; VectorType(*10*); LoadColumn(1, *10*)>]
        Features: float32 array
    }

    static member Build (label, features: float32 array) = { Label = label; Features = features }

I assume this has to be done through reflection, but I have no idea how to do that.

0

There are 0 best solutions below

Related Questions in F#