I am fairly new to Haskell and trying to improve myself as far as functional languages are concerned. I am attempting to create a function that will take a number of rows and columns and produce a 2D array as follows, for example:
arrayMaker :: (Int, Int) -> [[Int]]
-- use replicate function somehow to create each row?
The resulting matrix would appear as follows (for 5 rows, 3 columns):
[[14, 15, 16],
[13, 12, 11],
[8, 9, 10],
[7, 6, 5],
[2, 3, 4]]
Notice the values begin in the last row at 2. Also the array should alternate between ascending and descending rows. Help would be greatly appreciated
rowthat givenigenerates the i-th row. Thenmap row [1..numRows]. To do that, can you write a simple arithmetical formula for the number in position(i,j)wheniis even? and wheniis odd?