column v3, stop me if you can

master
karchnu 2016-01-16 01:03:16 +01:00
parent 4709700840
commit 0fa7141e6a
1 changed files with 13 additions and 0 deletions

13
haskell/columnv3.hs Normal file
View File

@ -0,0 +1,13 @@
import Data.List as L
formatLine :: [String] -> [String]
formatLine x = map (\e -> e ++ [' ' | _ <- [length e..nb]]) x
where nb = maximum $ map length x
completeMatrix :: [[String]] -> [[String]]
completeMatrix m = map (\e -> e ++ [""| _ <- [length e..nb]]) m
where nb = maximum $ map length m
main = do
content <- getContents
putStr $ unlines $ map unwords $ (L.transpose . (\x -> map formatLine x) . L.transpose . completeMatrix) $ map words $ lines content