1 2 3 4 5 6 7 8 9 10 11 | chunkify :: [Card] -> Int -> [Int] -> ([[Card]], [Int])
chunkify cards maxc rands = chunkify' cards rands
where
chunkify' :: [Card] -> [Int] -> ([[Card]], [Int])
chunkify' [] rs = ([], rs)
chunkify' cs [] = ([cs], [])
chunkify' cs (r:rs) = (chunk : result, rs')
where
(result, rs') = chunkify' remainingCards rs
(chunk, remainingCards) = splitAt pos cs
pos = (r `mod` maxc) + 1
|