avoid unncessary padding on last column in table

This commit is contained in:
Joey Hess 2015-01-15 19:56:18 -04:00
parent 56539e79e0
commit 95d1cc62ea
1 changed files with 2 additions and 1 deletions

View File

@ -22,7 +22,8 @@ formatTable table = map (\r -> unwords (map pad (zip r rowsizes))) table
where
pad (cell, size) = cell ++ take (size - length cell) padding
padding = repeat ' '
rowsizes = sumrows (map (map length) table)
rowsizes = reverse $ (0:) $ drop 1 $ reverse $
sumrows (map (map length) table)
sumrows [] = repeat 0
sumrows [r] = r
sumrows (r1:r2:rs) = sumrows $ map (uncurry max) (zip r1 r2) : rs