Last active
October 19, 2018 17:10
-
-
Save rudchenkos/ad56facf62a82eac52b3a9726de51ade to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module Language.Dutch.Telwoorden where | |
telwoord :: Integer -> String | |
telwoord 0 = "nul" | |
telwoord 1 = "een" | |
telwoord 2 = "twee" | |
telwoord 3 = "drie" | |
telwoord 4 = "vier" | |
telwoord 5 = "vijf" | |
telwoord 6 = "zes" | |
telwoord 7 = "zeven" | |
telwoord 8 = "acht" | |
telwoord 9 = "negen" | |
telwoord 10 = "tien" | |
telwoord 11 = "elf" | |
telwoord 12 = "twaalf" | |
telwoord 13 = "dertien" | |
telwoord 14 = "veertien" | |
telwoord n | n < 20 = concat [ telwoord (n `mod` 10), "tien" ] | |
telwoord n | n < 100 = decade (n `div` 10) (n `mod` 10) | |
where | |
decade d 0 = concat [ prefix d, "tig" ] | |
where | |
prefix 2 = "twin" | |
prefix 3 = "der" | |
prefix 4 = "veer" | |
prefix 8 = "tach" | |
prefix n = telwoord n | |
decade d r = concat [ telwoord r, "en", decade d 0 ] | |
telwoord n | n < 1000 = hundred (n `div` 100) (n `mod` 100) | |
where | |
hundred 1 0 = "honderd" | |
hundred h 0 = concat [ telwoord h, "honderd" ] | |
hundred h r = concat [ hundred h 0, telwoord r ] | |
telwoord n | n < 10000 = thousand (n `div` 1000) (n `div` 100 `mod` 10) (n `mod` 100) | |
where | |
-- t h d r -- thousands, hundreds, rest | |
thousand 1 0 0 = "duizend" | |
thousand t 0 0 = concat [ telwoord t, "duizend" ] | |
-- 2500 -> "vijventwintighonderd" | |
thousand t h 0 | t < 10 = concat [ telwoord (h + t * 10), "honderd" ] | |
-- 3001 -> "drieduizend-een" | |
thousand t d r | r < 10 = concat [ thousand t 0 0, "-", telwoord r] | |
thousand t h r = concat [ thousand t h 0 , "-", telwoord r ] | |
telwoord n = show n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment