Creating 2 dimensional list matrix

后端 未结 3 752
迷失自我
迷失自我 2021-01-24 17:07

How do you create a list-based matrix of 1\'s with given row and column counts? For example, like:

row=3,column=4 -> [[1,1,1,1],[1,1,1,1],[1,1,1         


        
3条回答
  •  一向
    一向 (楼主)
    2021-01-24 17:53

    import Control.Applicative
    import Data.Functor 
    
    matrix r c = [1] <* [1..c] <$ [1..r]
    

提交回复
热议问题