From a92640a487f0cb5165a2ff3cf39f8c7a58fa2fc5 Mon Sep 17 00:00:00 2001
From: karchnu <karchnu@karchnu.fr>
Date: Fri, 8 Jan 2016 04:29:12 +0100
Subject: [PATCH] columnv2 => moins de lignes, utilisation de list
 comprehension

---
 haskell/columnv2.hs | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 haskell/columnv2.hs

diff --git a/haskell/columnv2.hs b/haskell/columnv2.hs
new file mode 100644
index 0000000..9908872
--- /dev/null
+++ b/haskell/columnv2.hs
@@ -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