dynamically generated - Generate 2D list with given dimensions in Haskell -


I am trying to prepare a list of lists with a specified dimension. The data type of this list looks like this:

  data a = x | Y Z  

is therefore the list [[ A ]]. (A show type is an example of class, so do not worry about it).

The user gives a certain dimension (width = 3 and height = 4), so the content can appear like this:

  [[X, How do I  width  <, y, x], [y, y, x], [y, x, z], [x, z, z]]  

X can be 'em' height , 'value' is not all that important at this time.

<

Edit (for reasons of clarity)

I just want to know what kind of ' Matrix 'A'] with width and height as user input. Therefore the width = Internal list in the external list, height = number of elements in the number of lists.

To create a 3x4 nested list filled with a certain element, you can use it:

  data A = X | Y Jade leverage (Show) Width height = Repeat height. Generate 3 X 4 X  

to get the X . .

Keep in mind that nested lists are not a very good place for the 2D array in C / Java if targets are constantly updating points. In those cases, Data.Map or Use Data.Array .


Comments