Skip to content

Instantly share code, notes, and snippets.

@drewr
Created June 24, 2012 21:50
Show Gist options
  • Save drewr/2985146 to your computer and use it in GitHub Desktop.
Save drewr/2985146 to your computer and use it in GitHub Desktop.
import System.Environment
import Data.List
splitN :: Int -> [a] -> [[a]]
splitN n [] = []
splitN n xs =
[y] ++ (splitN n ys)
where (y, ys) = splitAt n xs
main = do
(n:_) <- getArgs
contents <- getContents
mapM_ putStr $
intersperse "-- \n" $
map unlines (splitN (read n) (words contents))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment