Skip to content

Instantly share code, notes, and snippets.

@fwgreen
Last active June 15, 2023 05:15
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 fwgreen/a77a9b059ce8e4771e55a9f42783fb53 to your computer and use it in GitHub Desktop.
Save fwgreen/a77a9b059ce8e4771e55a9f42783fb53 to your computer and use it in GitHub Desktop.
Chunk and friends
chunq :: Int -> [a] -> [[a]]
chunq _ [] = []
chunq n xs = let (first, remaining) = splitAt n xs in first : chunq n remaining
transpoze :: [[a]] -> [[a]]
transpoze [] = []
transpoze ([] : xss) = transpoze xss
transpoze ((x:xs) : xss) = (x : [h | (h:_) <- xss]) : transpoze (xs : [ t | (_:t) <- xss])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment