Skip to content

Instantly share code, notes, and snippets.

@dripolles
Last active August 29, 2015 13:57
Show Gist options
  • Save dripolles/9744417 to your computer and use it in GitHub Desktop.
Save dripolles/9744417 to your computer and use it in GitHub Desktop.
1HaskellADay 24/03/2014
-- http://codepad.org/rwuXZKKQ
import Data.List.Split
squareList :: Int -> a -> [a] -> [[a]]
squareList n z xs = let
(x', xs') = splitAt n $ xs ++ repeat z
in take n (x' : squareList n z xs')
squareList' :: Int -> a -> [a] -> [[a]]
squareList' n z xs = take n $ chunksOf n (xs ++ repeat z)
main = do
print $ squareList 5 0 [1..19]
print $ squareList' 5 0 [1..19]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment