Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Data.Textを使った九九の表の出力。
module Kuku where
import qualified Data.Text as T
import Data.Text (Text)
import qualified Data.Text.IO as TIO
-- general function
showText :: (Show a) => a -> Text
showText = T.pack . show
--
kuku :: [[Text]]
kuku = [ map ( formatInt . (x*) ) one2max | x <- one2max ]
where
size = 9
one2max = [1..size] :: [Int]
formatInt = rjust . showText
rjust = T.justifyRight digit ' '
digit = 1 + ( length $ show $ size * size )
kukuf :: Text
kukuf = T.unlines kukuls
where
kukuls = map T.concat kuku
main :: IO ()
main = TIO.putStr kukuf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment