Guest User

Untitled

a guest
Oct 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. {-
  2. - This is the matrix:
  3. - [
  4. - [(a0,b0), (a0,b1), (a0,b2), ..., (a0,bm)],
  5. - [(a1,b0), (a1,b1), (a1,b2), ..., (a1,bm)],
  6. - . . .
  7. - . . .
  8. - . . .
  9. - [(an,b0), (an,b1), (an,b2), ..., (an,bm)]
  10. - ]
  11. -
  12. - I want to create a function that returns a list (call it `fns`)
  13. - where each element is a list containing one element from each row
  14. - of the matrix, e.g. this could be one of the elements of `fns`:
  15. -
  16. - [(a0,b0), (a1,b1), ..., (an,b34)]
  17. -
  18. - The size of the matrix is variable, so the function has to work
  19. - for any matrix with dimension MxN. Basically, what I want is something
  20. - similar to this:
  21. -}
  22.  
  23. -- Only works for matrices with 2 rows.
  24. mkFuns (row:row2:[]) =
  25. do
  26. abn <- row
  27. abn2 <- row2
  28. return [abn, abn2]
  29.  
  30. {-
  31. - However, the problem is, I don't know how to do this for a variable
  32. - number of rows. Obviously, the above solution requires hard-coding the
  33. - number of rows (because I'm doing a monadic bind for each row). I don't
  34. - know if this is possible using do notation.
  35. -}
Add Comment
Please, Sign In to add comment