Add group function
This commit is contained in:
parent
18fe09a531
commit
8fc6e8acbc
@ -19,6 +19,11 @@ xs ?? n | n < 0 = Nothing
|
|||||||
(x:_) ?? 0 = Just x
|
(x:_) ?? 0 = Just x
|
||||||
(_:xs) ?? n = xs ?? (n-1)
|
(_: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
|
-- | Create a matrix of indeces of a matrix
|
||||||
indeces :: Mat a -> Mat Pos
|
indeces :: Mat a -> Mat Pos
|
||||||
indeces (Mat m) = Mat [[(x,y) | y <- [0..length (m !! x)-1]] |
|
indeces (Mat m) = Mat [[(x,y) | y <- [0..length (m !! x)-1]] |
|
||||||
|
Loading…
Reference in New Issue
Block a user