Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

19
Task/Nth/Haskell/nth.hs Normal file
View file

@ -0,0 +1,19 @@
import Data.Array
ordSuffs :: Array Integer String
ordSuffs = listArray (0,9) ["th", "st", "nd", "rd", "th",
"th", "th", "th", "th", "th"]
ordSuff :: Integer -> String
ordSuff n = show n ++ suff n
where suff m | (m `rem` 100) >= 11 && (m `rem` 100) <= 13 = "th"
| otherwise = ordSuffs ! (m `rem` 10)
printOrdSuffs :: [Integer] -> IO ()
printOrdSuffs = putStrLn . unwords . map ordSuff
main :: IO ()
main = do
printOrdSuffs [ 0.. 25]
printOrdSuffs [ 250.. 265]
printOrdSuffs [1000..1025]