some-usable-scripts/haskell/columnv3.hs

14 lines
493 B
Haskell
Raw Permalink Normal View History

2016-01-16 01:03:16 +01:00
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
2016-01-16 01:24:46 +01:00
putStr $ unlines $ map unwords $ L.transpose $ map formatLine $ L.transpose $ completeMatrix $ map words $ lines content