A 2D array is not irregular, so similar to java you need to declare an array
of an array
of int
s. In F# that's int array array
and zeroCreate needs to know what type it's going to initialize an array for. Also be careful of indentation, your nested for loops weren't indented properly.
open System
type MatrizIrregular() =
let irregular : int array array = Array.zeroCreate 5
member This.Inicializar() =
for f in 0 .. 4 do
printf "Introduzcal el número de columnas de la matriz de la fila %d: " f
let res = Console.ReadLine()
let col = Int32.Parse(res)
let cols : int array = Array.zeroCreate col
for c in 0 .. col - 1 do
printf "Introduzca el valor de la columna %d: " c
let res2 = Console.ReadLine()
Array.set cols c (Int32.Parse(res2))
Array.set irregular f cols
member This.Mostrar() =
for f in 0 .. 4 do
for c in 0 .. (Array.length irregular.[f]) - 1 do
printf "%d " irregular.[f].[c]
printf "\n"
let matriz = MatrizIrregular()
matriz.Inicializar()
matriz.Mostrar()
Not the most functional answer, but it is what was asked for.