Last active
September 21, 2018 18:54
-
-
Save DylanLukes/cbb85d30524c2e32b1643d5fa42b48d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List.Split | |
nFiniteChunks :: Int -> [a] -> [[a]] | |
nFiniteChunks n xs = splitPlaces places xs | |
where len = length xs | |
hi = len `div` n + 1 | |
lo = len `div` n | |
nHi = len - lo * n | |
nLo = hi * n - len | |
places = (replicate nHi hi) ++ (replicate nLo lo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment