Skip to content

Instantly share code, notes, and snippets.

@igrep
Created September 9, 2012 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igrep/3683344 to your computer and use it in GitHub Desktop.
Save igrep/3683344 to your computer and use it in GitHub Desktop.
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