Created
March 7, 2010 14:23
-
-
Save jutememo/324385 to your computer and use it in GitHub Desktop.
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
-- ページ | |
data Page = Page [String] | |
-- 文字列をページに変換 | |
toPage :: String -> Page | |
toPage = Page . lines | |
main = getContents >>= print . toPage | |
instance Show Page where | |
show (Page ls) = unlines $ map (padding 6) (zip [1..] ls) | |
-- 行 line に幅 width で行番号 n をふる | |
padding width (n,line) = spaces ++ num ++ " " ++ line | |
where | |
spaces = replicate (width - length num) ' ' | |
num = show n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment