Sha256: 6d3f5aa957d2b2172c9d0a2afcf034af107a42a48b4583a874a4b8290dbb00e6
Contents?: true
Size: 490 Bytes
Versions: 73
Compression:
Stored size: 490 Bytes
Contents
module Diamond (diamond) where import Data.Char (ord, chr) pad :: Int -> String pad x = replicate x ' ' oneRow :: Char -> (Int, Int) -> String oneRow c (0, y) = pad y ++ [c] ++ pad y oneRow c (x, y) = pad y ++ [c] ++ pad x ++ [c] ++ pad y diamond :: Char -> Maybe [String] diamond = Just . (\x -> x ++ tail (reverse x)) . mkTop . subtract 64 . ord where rows x = zip (0 : take (x-1) [1, 3..]) [x-1, x-2..0] mkTop = zipWith oneRow abc . rows abc = map chr [65..90]
Version data entries
73 entries across 73 versions & 1 rubygems