Skip to content

Instantly share code, notes, and snippets.

@MgaMPKAy
Created June 10, 2012 15:36
Show Gist options
  • Save MgaMPKAy/2906253 to your computer and use it in GitHub Desktop.
Save MgaMPKAy/2906253 to your computer and use it in GitHub Desktop.
print
module Main where
import Data.List (intersperse)
padding :: String -> Int -> String
padding str n
| length str >= n * 2 = str
| otherwise = let l = (n * 2 - length str) `div` 2
in replicate l ' ' ++ str ++ replicate l ' '
top :: Char -> Int -> [String]
top c n = let s1 = [f c | f <- map replicate [1..n]]
s2 = map (intersperse ' ') s1
s3 = map ((flip padding) n) s2
in s3
buttom :: Char -> Int -> [String]
buttom c n = reverse $ take (n - 1) $ top c n
topAndButton ct cb n = top ct n ++ buttom cb n
gen ct cb n x
| x == 1 = tb
| otherwise = zipWith (++) tb (gen ct cb n (x - 1))
where tb = topAndButton ct cb n
final ct cb n x = mapM_ putStrLn $ gen ct cb n x
{-- example output
final 'A' 'V' 6 3 =
A A A
A A A A A A
A A A A A A A A A
A A A A A A A A A A A A
A A A A A A A A A A A A A A A
A A A A A AA A A A A AA A A A A A
V V V V V V V V V V V V V V V
V V V V V V V V V V V V
V V V V V V V V V
V V V V V V
V V V
--}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment