Use applicative style
This commit is contained in:
parent
8fc6e8acbc
commit
7b97c9c65d
@ -1,4 +1,6 @@
|
||||
module Matrix where
|
||||
|
||||
import Control.Applicative
|
||||
import Data.List (intercalate)
|
||||
|
||||
newtype Mat a = Mat [[a]]
|
||||
@ -26,8 +28,9 @@ group n xs = take n xs : group n (drop n xs)
|
||||
|
||||
-- | Create a matrix of indeces of a matrix
|
||||
indeces :: Mat a -> Mat Pos
|
||||
indeces (Mat m) = Mat [[(x,y) | y <- [0..length (m !! x)-1]] |
|
||||
x <- [0..length m-1]]
|
||||
indeces (Mat m) = Mat (group y pos) where
|
||||
(x, y) = (length m, length (m !! 0))
|
||||
pos = liftA2 (,) [0..x-1] [0..y-1]
|
||||
|
||||
-- | Create a constant matrix
|
||||
constant :: a -> Int -> Int -> Mat a
|
||||
|
Loading…
Reference in New Issue
Block a user