-
-
Save mmynsted/7831dbd552c1f874143c0e0d5807a4c8 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
{-# LANGUAGE OverloadedStrings #-} | |
module Main | |
where | |
-- import Data.Text as T | |
main = putStrLn $ f 2 | |
f :: Int -> String | |
f n | |
| n < 0 = mconcat $ take 3 x | |
| n > 3 = mconcat $ take 3 y | |
| otherwise = mconcat $ take n y <> take (3 - n) x | |
where | |
x = "☆" : x | |
y = "★" : y |
treblacy
commented
Dec 4, 2020
{-# LANGUAGE OverloadedStrings #-}
module Main
where
import Data.Text as T
main = putStrLn $ unpack $ f 2
f :: Int -> Text
f n
| n < 0 = mconcat $ Prelude.take 3 x
| n > 3 = mconcat $ Prelude.take 3 y
| otherwise = mconcat $ Prelude.take n y <> Prelude.take (3 - n) x
where
x = ("☆" :: Text) : x
y = ("★" :: Text) : y
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment