From 0fa7141e6aea7051a0d7cf476ef041fbbec1a715 Mon Sep 17 00:00:00 2001
From: karchnu <karchnu@karchnu.fr>
Date: Sat, 16 Jan 2016 01:03:16 +0100
Subject: [PATCH] column v3, stop me if you can

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

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