nove, cinco, um :: [Int] nove = [4,1,4,2,1,2,1] cinco = [4,2,3,2,4] um = [0,2,1,2,1,2,1,2,1,2,1] dois = [3,2,5,2,3] tres = [3,2,4,2,4] quatro = [1,1,2,1,4,2,1,2,1] seis = [4,2,4,1,4] sete = [3,2,1,2,1,2,1,2,1] oito = [4,1,5,1,4] zer = [4,1,2,1,2,1,4] type Linha = String toString :: [Int] ->String toString [] = "" toString (a:[]) = nChar a '*' toString (a:b:x) = nChar a '*' ++ nChar b ' ' ++ toString x nChar :: Int -> Char -> String nChar 0 _ = "" nChar n c = [c] ++ nChar (n-1) c toLinhas :: String -> [Linha] toLinhas [] = [] toLinhas l = (take 3 l) : toLinhas(drop 3 l) showLinhas :: [Linha] -> String showLinhas [] = "" showLinhas (a:x) = a++"\n"++showLinhas x juntaLinhas :: [Linha] -> [Linha] -> [Linha] juntaLinhas l1 [] = l1 juntaLinhas [] l2 = l2 juntaLinhas (a:as) (b:bs) = (a++" "++b) : juntaLinhas as bs numeros :: [[Int]] numeros = [zer,um,dois,tres,quatro,cinco,seis,sete,oito,nove] tolcd :: Int -> String tolcd n | (n>=0) && (n<10) = showLinhas (toLinhas (toString (aux n))) | (n>=10) && (n<100) = showLinhas(juntaLinhas (toLinhas (toString (aux(div n 10)))) (toLinhas (toString (aux(mod n 10))))) | (n>=100) && (n<1000) = showLinhas (juntaLinhas (toLinhas (toString (aux(div n 100)))) (juntaLinhas (toLinhas (toString (aux(div (mod n 100) 10)))) (toLinhas (toString (aux(mod (mod n 100) 10)))))) aux :: Int -> [Int] aux 0 = head numeros aux n = head (drop n numeros) toCompact :: String -> [Int] toCompact [] = [] toCompact (a:as) | a == '*' = (asterisco (a:as)) : toCompact (drop (asterisco (a:as)) (a:as) ) | otherwise = (espacoBranco (a:as)) : toCompact (drop ( espacoBranco (a:as)) (a:as) ) asterisco :: String -> Int asterisco [] = 0 asterisco (a:as) | a == '*' = 1 + asterisco as | otherwise = 0 espacoBranco :: String -> Int espacoBranco [] = 0 espacoBranco (a:as) | a == ' ' = 1 + espacoBranco as | otherwise = 0