









Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!










Hugs> :type show show :: Show a => a -> String Hugs> show 1 "1" Hugs> show 45. "45.4" Hugs> show [1,2,3] "[1,2,3]" Hugs> show ((+) 1 2) "3" Hugs> show ((+) 1 2) ++ show ((div) 4 2) "32" Hugs> show ((+) 1 2) ++ show ((/) 4 2) "32.0"
iguaisInt :: Int -> Int -> Int -> Bool iguaisInt n m p = (n == m) && (m == p) iguais :: Eq t => t -> t -> t -> Bool iguais n m p = (n == m) && (m == p) Main> iguaisInt 1 2 3 False Main> iguais 'c' 'c' 'c' True
f:: Num a => a -> [b] -> [b] ->(a,[b]) f x y z = (x + 1, y ++ z) Main> [1] ++ [2] [1,2] Main> [1,2] ++ [3,4] [1,2,3,4] Main> :type (++) (++) :: [a] -> [a] -> [a] Main> f 1 [2] [3] Main> f 1 2 3 Main> f 1 ['a'] ['b']
class Eq t => Ord t where (<),(<=),(>),(>=) :: t -> t -> Bool max, min :: t -> t -> t a <= b = (a < b || a == b) a > b = b < a a < b = b > a a >= b = (a > b || a == b) iSort :: Ord t => [t] ->[t] A classe Eq é superclasse de Ord
Int, Integer Float, Double Rational Complex Classes: Num, Real, Fractional, Floating rep 0 ch = [] rep n ch = ch : rep (n-1) ch Main> :type rep rep :: Num a => a -> b -> [b] Main> rep 4 'd' (??) Main> rep 4 2 (??)