Created
June 26, 2018 18:12
-
-
Save md2perpe/6cb9d6bcd88ae0c73af6e44d952f26a3 to your computer and use it in GitHub Desktop.
En talföljd
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
toSwedish :: Integer -> String | |
toSwedish 1 = "ett" | |
toSwedish 2 = "två" | |
toSwedish 3 = "tre" | |
toSwedish 4 = "fyra" | |
toSwedish 5 = "fem" | |
toSwedish 6 = "sex" | |
toSwedish 7 = "sju" | |
toSwedish 8 = "åtta" | |
toSwedish 9 = "nio" | |
toSwedish 10 = "tio" | |
toSwedish 11 = "elva" | |
toSwedish 12 = "tolv" | |
toSwedish 13 = "tretton" | |
toSwedish 14 = "fjorton" | |
toSwedish 15 = "femton" | |
toSwedish 16 = "sexton" | |
toSwedish 17 = "sjutton" | |
toSwedish 18 = "arton" | |
toSwedish 19 = "nitton" | |
toSwedish 20 = "tjugo" | |
toSwedish 30 = "trettio" | |
toSwedish 40 = "fyrtio" | |
toSwedish 50 = "femtio" | |
toSwedish 60 = "sextio" | |
toSwedish 70 = "sjuttio" | |
toSwedish 80 = "åttio" | |
toSwedish 90 = "nittio" | |
toSwedish n | 20 < n && n < 100 = | |
let ental = n `mod` 10 | |
in toSwedish (n - ental) ++ toSwedish ental | |
sequence = map (length . toSwedish) [1..99] | |
main = print $ show $ sequence |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment