Created
September 9, 2012 08:34
-
-
Save igrep/3683344 to your computer and use it in GitHub Desktop.
Data.Textを使った九九の表の出力。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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