diff --git a/Matrix.hs b/Matrix.hs index febbd0b..dc66cd4 100644 --- a/Matrix.hs +++ b/Matrix.hs @@ -19,6 +19,11 @@ xs ?? n | n < 0 = Nothing (x:_) ?? 0 = Just x (_:xs) ?? n = xs ?? (n-1) +-- | Split a list into sublists of length n +-- group 2 [1..5] == [[1,2],[3,4],[5]] +group _ [] = [] +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]] |