Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-
- - This is the matrix:
- - [
- - [(a0,b0), (a0,b1), (a0,b2), ..., (a0,bm)],
- - [(a1,b0), (a1,b1), (a1,b2), ..., (a1,bm)],
- - . . .
- - . . .
- - . . .
- - [(an,b0), (an,b1), (an,b2), ..., (an,bm)]
- - ]
- -
- - I want to create a function that returns a list (call it `fns`)
- - where each element is a list containing one element from each row
- - of the matrix, e.g. this could be one of the elements of `fns`:
- -
- - [(a0,b0), (a1,b1), ..., (an,b34)]
- -
- - The size of the matrix is variable, so the function has to work
- - for any matrix with dimension MxN. Basically, what I want is something
- - similar to this:
- -}
- -- Only works for matrices with 2 rows.
- mkFuns (row:row2:[]) =
- do
- abn <- row
- abn2 <- row2
- return [abn, abn2]
- {-
- - However, the problem is, I don't know how to do this for a variable
- - number of rows. Obviously, the above solution requires hard-coding the
- - number of rows (because I'm doing a monadic bind for each row). I don't
- - know if this is possible using do notation.
- -}
Add Comment
Please, Sign In to add comment