Skip to content

Instantly share code, notes, and snippets.

@DylanLukes
Last active September 21, 2018 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DylanLukes/cbb85d30524c2e32b1643d5fa42b48d9 to your computer and use it in GitHub Desktop.
Save DylanLukes/cbb85d30524c2e32b1643d5fa42b48d9 to your computer and use it in GitHub Desktop.
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