<commit_before>module Diamond
  ( diamond
  ) where

import Data.Char (ord)

diamond :: Char -> Maybe [String]
diamond c = (mirror . upperHalf) <$> Just c

upperHalf endChar = zipWith (curry line) [0 ..] ['A' .. endChar]
  where
    line = mirror . makeLine (distanceFromA endChar)

distanceFromA c = ord c - ord 'A'

makeLine :: Int -> (Int, Char) -> String
makeLine length (index, character) = spaces (length - index) ++ [character] ++ spaces index

spaces :: Int -> String
spaces n = replicate n ' '

mirror :: [a] -> [a]
mirror = mirrored >>= flip (++)
  where
    mirrored = reverse . init<commit_msg>solved the whole exercise<commit_after>module Diamond
  ( diamond
  ) where

import Data.Char (ord)

diamond :: Char -> Maybe [String]
diamond c = (mirror . makeUpperHalf) <$> Just c

makeUpperHalf :: Char -> [String]
makeUpperHalf endChar = zipWith (curry line) [0 ..] ['A' .. endChar]
  where
    line = mirror . makeLine distanceFromA
    distanceFromA = ord endChar - ord 'A'

makeLine :: Int -> (Int, Char) -> String
makeLine length (index, character) =
  spaces (length - index) ++ [character] ++ spaces index

spaces :: Int -> String
spaces n = replicate n ' '

mirror :: [a] -> [a]
mirror = (reverse . init) >>= flip (++)
{'fraction_non_alphanumeric': 0.14817813765182186, 'fraction_numerical': 0.0016194331983805667, 'mean_word_length': 3.398576512455516, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7124934', 'n_tokens_mistral': 420, 'n_tokens_neox': 398, 'n_words': 138}