X-Git-Url: https://mattmccutchen.net/match/match.git/blobdiff_plain/967c39efa10c8a2d74812741cd7a2a96602a6210..00819c1910f1e9bdad75fc2740792e867d517d58:/program/Formatter.hs diff --git a/program/Formatter.hs b/program/Formatter.hs index 5ee5a00..aab845c 100644 --- a/program/Formatter.hs +++ b/program/Formatter.hs @@ -1,10 +1,18 @@ module Formatter where import Data.List +#if __GLASGOW_HASKELL__ <= 606 +intercalate xs xss = concat (intersperse xs xss) +#endif + padWith :: a -> Int -> [a] -> [a] padWith _ 0 l = l padWith e n [] = replicate n e -padWith e (n+1) (h:t) = h:(padWith e n t) +-- http://hackage.haskell.org/trac/haskell-prime/wiki/RemoveNPlusK +-- Ugg... GHC could at least give a meaningful error message. ~ Matt 2011-08-27 +padWith e n (h:t) = + if n == 0 then error "padWith: list is already longer than the requested length" + else h:(padWith e (n-1) t) formatTable :: [[String]] -> String formatTable cells =