Notas para o segundo teste

Key Concepts

Important Details

Examples

Questions

Summary

  • Preguntas
multThree :: (Num a) => a -> a -> a -> a  
multThree x y z = x * y * z 
ghci> let multTwoWithNine = multThree 9  
ghci> multTwoWithNine 2 3  
54  
ghci> let multWithEighteen = multTwoWithNine 2  
ghci> multWithEighteen 10  
180 
data Either a b = Left a | Right b deriving (EqOrdReadShow) 

acumuladores

pmaior :: [Int] -> Int -> Int  
-- pmaior [4, 3, 12, 5] = 2
pmaior lista@(x:xs) acc | if max lista == x then 0 else 
						| otherwise pmaior xs (acc + 1) = ... (FIX ME)
pmaiorA :: (Int, Int, Int) -> [Int] -> Int
pmaiorA (m, pm, p) [] = pm 
pmaiorA (m, pm. p) (h:t) | h > m = pmaiorA (h, p, p + 1) t
						   | otherwise = pmaiorA (m, pm , p + 1) t 
mP :: [Int] -> (Int, Int)
mP [x] = (x, 0) 
mP (h:t) | h > x = (h, 0)
		 | otherwise = (x, p + 1)
	where (x, p) = mP t 
isLeft :: Either a b -> Bool 
isLeft (Left _) = True 
isLeft _ = False 
 
 
separaE :: [Either a b] -> ([a], [b])
separaE lista@(h:t) = ([a | Left a <- l], [b ])