columnv2 => moins de lignes, utilisation de list comprehension
parent
c20d0b6e0b
commit
a92640a487
|
@ -0,0 +1,19 @@
|
|||
import Data.List as L
|
||||
|
||||
formatLine :: [String] -> [String]
|
||||
formatLine x = map (\e -> e ++ [' ' | _ <- [length e..nb]]) x
|
||||
where nb = maximum $ map length x
|
||||
|
||||
formatLines :: [[String]] -> [[String]]
|
||||
formatLines x = map formatLine x
|
||||
|
||||
completeMatrix :: [[String]] -> [[String]]
|
||||
completeMatrix m = map (\e -> e ++ [""| _ <- [length e..nb]]) m
|
||||
where nb = maximum $ map length m
|
||||
|
||||
column :: [[String]] -> [[String]]
|
||||
column x = L.transpose $ formatLines $ L.transpose $ completeMatrix x
|
||||
|
||||
main = do
|
||||
content <- getContents
|
||||
putStr $ unlines $ map unwords $ column $ map words $ lines content
|
Loading…
Reference in New Issue